template.php

Same filename in this branch
  1. 7.x themes/garland/template.php
  2. 7.x themes/bartik/template.php
  3. 7.x modules/simpletest/tests/themes/test_theme/template.php
Same filename in other branches
  1. 9 core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/Annotation/Template.php
  2. 8.9.x core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/Annotation/Template.php
  3. 10 core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/Annotation/Template.php
  4. 11.x core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/Annotation/Template.php

File

themes/seven/template.php

View source
<?php


/**
 * Override or insert variables into the maintenance page template.
 */
function seven_preprocess_maintenance_page(&$vars) {
    // While markup for normal pages is split into page.tpl.php and html.tpl.php,
    // the markup for the maintenance page is all in the single
    // maintenance-page.tpl.php template. So, to have what's done in
    // seven_preprocess_html() also happen on the maintenance page, it has to be
    // called here.
    seven_preprocess_html($vars);
}

/**
 * Override or insert variables into the html template.
 */
function seven_preprocess_html(&$vars) {
    // Add conditional CSS for IE8 and below.
    drupal_add_css(path_to_theme() . '/ie.css', array(
        'group' => CSS_THEME,
        'browsers' => array(
            'IE' => 'lte IE 8',
            '!IE' => FALSE,
        ),
        'weight' => 999,
        'preprocess' => FALSE,
    ));
    // Add conditional CSS for IE7 and below.
    drupal_add_css(path_to_theme() . '/ie7.css', array(
        'group' => CSS_THEME,
        'browsers' => array(
            'IE' => 'lte IE 7',
            '!IE' => FALSE,
        ),
        'weight' => 999,
        'preprocess' => FALSE,
    ));
    // Add conditional CSS for IE6.
    drupal_add_css(path_to_theme() . '/ie6.css', array(
        'group' => CSS_THEME,
        'browsers' => array(
            'IE' => 'lte IE 6',
            '!IE' => FALSE,
        ),
        'weight' => 999,
        'preprocess' => FALSE,
    ));
}

/**
 * Override or insert variables into the page template.
 */
function seven_preprocess_page(&$vars) {
    $vars['primary_local_tasks'] = $vars['tabs'];
    unset($vars['primary_local_tasks']['#secondary']);
    $vars['secondary_local_tasks'] = array(
        '#theme' => 'menu_local_tasks',
        '#secondary' => $vars['tabs']['#secondary'],
    );
}

/**
 * Display the list of available node types for node creation.
 */
function seven_node_add_list($variables) {
    $content = $variables['content'];
    $output = '';
    if ($content) {
        $output = '<ul class="admin-list">';
        foreach ($content as $item) {
            $output .= '<li class="clearfix">';
            $output .= '<span class="label">' . l($item['title'], $item['href'], $item['localized_options']) . '</span>';
            $output .= '<div class="description">' . filter_xss_admin($item['description']) . '</div>';
            $output .= '</li>';
        }
        $output .= '</ul>';
    }
    else {
        $output = '<p>' . t('You have not created any content types yet. Go to the <a href="@create-content">content type creation page</a> to add a new content type.', array(
            '@create-content' => url('admin/structure/types/add'),
        )) . '</p>';
    }
    return $output;
}

/**
 * Overrides theme_admin_block_content().
 *
 * Use unordered list markup in both compact and extended mode.
 */
function seven_admin_block_content($variables) {
    $content = $variables['content'];
    $output = '';
    if (!empty($content)) {
        $output = system_admin_compact_mode() ? '<ul class="admin-list compact">' : '<ul class="admin-list">';
        foreach ($content as $item) {
            $output .= '<li class="leaf">';
            $output .= l($item['title'], $item['href'], $item['localized_options']);
            if (isset($item['description']) && !system_admin_compact_mode()) {
                $output .= '<div class="description">' . filter_xss_admin($item['description']) . '</div>';
            }
            $output .= '</li>';
        }
        $output .= '</ul>';
    }
    return $output;
}

/**
 * Override of theme_tablesort_indicator().
 *
 * Use our own image versions, so they show up as black and not gray on gray.
 */
function seven_tablesort_indicator($variables) {
    $style = $variables['style'];
    $theme_path = drupal_get_path('theme', 'seven');
    if ($style == 'asc') {
        return theme('image', array(
            'path' => $theme_path . '/images/arrow-asc.png',
            'alt' => t('sort ascending'),
            'width' => 13,
            'height' => 13,
            'title' => t('sort ascending'),
        ));
    }
    else {
        return theme('image', array(
            'path' => $theme_path . '/images/arrow-desc.png',
            'alt' => t('sort descending'),
            'width' => 13,
            'height' => 13,
            'title' => t('sort descending'),
        ));
    }
}

/**
 * Implements hook_css_alter().
 */
function seven_css_alter(&$css) {
    // Use Seven's vertical tabs style instead of the default one.
    if (isset($css['misc/vertical-tabs.css'])) {
        $css['misc/vertical-tabs.css']['data'] = drupal_get_path('theme', 'seven') . '/vertical-tabs.css';
        $css['misc/vertical-tabs.css']['type'] = 'file';
    }
    if (isset($css['misc/vertical-tabs-rtl.css'])) {
        $css['misc/vertical-tabs-rtl.css']['data'] = drupal_get_path('theme', 'seven') . '/vertical-tabs-rtl.css';
        $css['misc/vertical-tabs-rtl.css']['type'] = 'file';
    }
    // Use Seven's jQuery UI theme style instead of the default one.
    if (isset($css['misc/ui/jquery.ui.theme.css'])) {
        $css['misc/ui/jquery.ui.theme.css']['data'] = drupal_get_path('theme', 'seven') . '/jquery.ui.theme.css';
        $css['misc/ui/jquery.ui.theme.css']['type'] = 'file';
    }
}

Functions

Title Deprecated Summary
seven_admin_block_content Overrides theme_admin_block_content().
seven_css_alter Implements hook_css_alter().
seven_node_add_list Display the list of available node types for node creation.
seven_preprocess_html Override or insert variables into the html template.
seven_preprocess_maintenance_page Override or insert variables into the maintenance page template.
seven_preprocess_page Override or insert variables into the page template.
seven_tablesort_indicator Override of theme_tablesort_indicator().

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.