/**
 * The Zen theme allows its subthemes to have their own template.php files
 * The only restriction with these files is that they cannot redefine any of the
 * functions that are already defined in Zen's main template.php file.
 *
 * Also remember that the "main" theme is still Zen, so your theme functions
 * should be named as such:
 *  theme_block()  becomes  zen_block()
 *  theme_feed_icon() becomes zen_feed_icon() as well
 *
 * Additionally, it is not possible for subthemes to redefine regions.
 *
 * For a subtheme to add its own variables, use the function name
 *   zen_variables($hook, $vars)
 */
function zen_variables($hook, $vars)
{
    $vars['subtheme_directory'] = path_to_subtheme();
    switch ($hook) {
        case 'page':
            // add main Zen styles
            drupal_add_css($vars['directory'] . '/layout.css', 'theme', 'all');
            drupal_add_css($vars['directory'] . '/icons.css', 'theme', 'all');
            drupal_add_css($vars['directory'] . '/zen.css', 'theme', 'all');
            drupal_add_css($vars['directory'] . '/print.css', 'theme', 'print');
            // then load the overrides for the above css
            $vars['css'] = drupal_add_css($vars['subtheme_directory'] . '/overrides.css', 'theme', 'all');
            $vars['styles'] = drupal_get_css();
    }
    return $vars;
}
Beispiel #2
0
/**
 * Allow sub-themes to have their own .tpl.php template files.
 *
 * This is an exact copy of _phptemplate_default() with the addition of the
 * $theme_path and $parent_theme_path
 */
function _zen_default($hook, $variables, $suggestions = array(), $extension = '.tpl.php')
{
    global $theme_engine;
    if ($theme_path = path_to_subtheme()) {
        $parent_theme_path = path_to_theme();
    } else {
        $theme_path = path_to_theme();
    }
    // Loop through any suggestions in FIFO order.
    $suggestions = array_reverse($suggestions);
    foreach ($suggestions as $suggestion) {
        if (!empty($suggestion)) {
            if (file_exists($theme_path . '/' . $suggestion . $extension)) {
                $file = $theme_path . '/' . $suggestion . $extension;
                break;
            } elseif (!empty($parent_theme_path) && file_exists($parent_theme_path . '/' . $suggestion . $extension)) {
                $file = $parent_theme_path . '/' . $suggestion . $extension;
                break;
            }
        }
    }
    if (!isset($file)) {
        if (file_exists($theme_path . "/{$hook}{$extension}")) {
            $file = $theme_path . "/{$hook}{$extension}";
        } elseif (!empty($parent_theme_path) && file_exists($parent_theme_path . "/{$hook}{$extension}")) {
            $file = $parent_theme_path . "/{$hook}{$extension}";
        } else {
            if (in_array($hook, array('node', 'block', 'box', 'comment'))) {
                $file = path_to_engine() . '/' . $hook . $extension;
            } else {
                $variables['hook'] = $hook;
                watchdog('error', t('%engine.engine was instructed to override the %name theme function, but no valid template file was found.', array('%engine' => $theme_engine, '%name' => $hook)));
                $file = path_to_engine() . '/default' . $extension;
            }
        }
    }
    if (isset($file)) {
        return call_user_func('_' . $theme_engine . '_render', $file, $variables);
    }
}
Beispiel #3
0
 */
include_once './' . drupal_get_path('theme', 'zen') . '/template.php';
/*
 * Add the stylesheets you will need for this sub-theme.
 *
 * To add stylesheets that are in the main Zen folder, use path_to_theme().
 * To add stylesheets that are in your sub-theme's folder, use path_to_subtheme().
 */
// Add any stylesheets you would like from the main Zen theme.
drupal_add_css(path_to_theme() . '/html-elements.css', 'theme', 'all');
drupal_add_css(path_to_theme() . '/tabs.css', 'theme', 'all');
// Then add styles for this sub-theme.
drupal_add_css(path_to_subtheme() . '/layout.css', 'theme', 'all');
drupal_add_css(path_to_subtheme() . '/nabuur_blog.css', 'theme', 'all');
// Avoid IE5 bug that always loads @import print stylesheets
zen_add_print_css(path_to_subtheme() . '/print.css');
/**
 * Declare the available regions implemented by this theme.
 *
 * @return
 *   An array of regions.
 */
/* -- Delete this line if you want to use this function
function nabuur_blog_regions() {
  return array(
    'left' => t('left sidebar'),
    'right' => t('right sidebar'),
    'navbar' => t('navigation bar'),
    'content_top' => t('content top'),
    'content_bottom' => t('content bottom'),
    'header' => t('header'),
Beispiel #4
0
/**
 * Override or insert PHPTemplate variables into the page templates.
 *
 * @param $vars
 *   A sequential array of variables to pass to the theme template.
 */
function zen_preprocess_page(&$vars)
{
    global $theme, $theme_key;
    // Allow sub-themes to have an ie.css or wireframes.css file.
    $vars['subtheme_directory'] = path_to_subtheme();
    // These next lines add additional CSS files and redefine
    // the $css and $styles variables available to your page template
    if ($theme == $theme_key) {
        // If we're in the main theme
        // Load the stylesheet for a liquid layout
        if (theme_get_setting('zen_layout') == 'border-politics-liquid') {
            drupal_add_css($vars['directory'] . '/layout-liquid.css', 'theme', 'all');
        } else {
            drupal_add_css($vars['directory'] . '/layout-fixed.css', 'theme', 'all');
        }
        drupal_add_css($vars['directory'] . '/html-elements.css', 'theme', 'all');
        drupal_add_css($vars['directory'] . '/tabs.css', 'theme', 'all');
        drupal_add_css($vars['directory'] . '/zen.css', 'theme', 'all');
        // Avoid IE5 bug that always loads @import print stylesheets
        $vars['head'] = zen_add_print_css($vars['directory'] . '/print.css');
    }
    // Optionally add the block editing styles.
    if (theme_get_setting('zen_block_editing')) {
        drupal_add_css($vars['directory'] . '/block-editing.css', 'theme', 'all');
    }
    // Optionally add the wireframes style.
    if (theme_get_setting('zen_wireframes')) {
        if ($vars['subtheme_directory'] && file_exists($vars['subtheme_directory'] . '/wireframes.css')) {
            drupal_add_css($vars['subtheme_directory'] . '/wireframes.css', 'theme', 'all');
        } else {
            drupal_add_css($vars['directory'] . '/wireframes.css', 'theme', 'all');
        }
    }
    $vars['css'] = drupal_add_css();
    $vars['styles'] = drupal_get_css();
    // Add an optional title to the end of the breadcrumb.
    if (theme_get_setting('zen_breadcrumb_title') && $vars['breadcrumb']) {
        $vars['breadcrumb'] = substr($vars['breadcrumb'], 0, -6) . $vars['title'] . '</div>';
    }
    // Don't display empty help from node_help().
    if ($vars['help'] == "<div class=\"help\"><p></p>\n</div>") {
        $vars['help'] = '';
    }
    // Optionally disabled the primary and secondary links.
    if (!theme_get_setting('zen_primary_links')) {
        $vars['primary_links'] = '';
    }
    if (!theme_get_setting('zen_secondary_links')) {
        $vars['secondary_links'] = '';
    }
    // Classes for body element. Allows advanced theming based on context
    // (home page, node of certain type, etc.)
    $classes = array();
    $classes[] = $vars['is_front'] ? 'front' : 'not-front';
    $classes[] = $vars['logged_in'] ? 'logged-in' : 'not-logged-in';
    if ($vars['node']->type) {
        // If on an individual node page, put the node type in the body classes
        $classes[] = 'node-type-' . $vars['node']->type;
    }
    if ($vars['sidebar_left'] && $vars['sidebar_right']) {
        $classes[] = 'two-sidebars';
    } elseif ($vars['sidebar_left']) {
        $classes[] = 'one-sidebar sidebar-left';
    } elseif ($vars['sidebar_right']) {
        $classes[] = 'one-sidebar sidebar-right';
    } else {
        $classes[] = 'no-sidebars';
    }
    if (!$vars['is_front']) {
        // Add unique class for each page.
        $path = drupal_get_path_alias($_GET['q']);
        $classes[] = zen_id_safe('page-' . $path);
        // Add unique class for each website section.
        list($section, ) = explode('/', $path, 2);
        if (arg(0) == 'node') {
            if (arg(1) == 'add') {
                $section = 'node-add';
            } elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) {
                $section = 'node-' . arg(2);
            }
        }
        $classes[] = zen_id_safe('section-' . $section);
    }
    $vars['body_classes_array'] = $classes;
    $vars['body_classes'] = implode(' ', $classes);
    // Concatenate with spaces.
}