Mercurial > hg > soundsoftware-drupal-theme
view template.php @ 7:787c247a1b22 tip
Minor font change
author | Chris Cannam |
---|---|
date | Thu, 15 Nov 2012 10:58:56 +0000 |
parents | 6b9d46abd911 |
children |
line wrap: on
line source
<?php // $Id: template.php,v 1.17.2.1 2009/02/13 06:47:44 johnalbin Exp $ /** * @file * Contains theme override functions and preprocess functions for the theme. * * ABOUT THE TEMPLATE.PHP FILE * * The template.php file is one of the most useful files when creating or * modifying Drupal themes. You can add new regions for block content, modify * or override Drupal's theme functions, intercept or make additional * variables available to your theme, and create custom PHP logic. For more * information, please visit the Theme Developer's Guide on Drupal.org: * http://drupal.org/theme-guide * * OVERRIDING THEME FUNCTIONS * * The Drupal theme system uses special theme functions to generate HTML * output automatically. Often we wish to customize this HTML output. To do * this, we have to override the theme function. You have to first find the * theme function that generates the output, and then "catch" it and modify it * here. The easiest way to do it is to copy the original function in its * entirety and paste it here, changing the prefix from theme_ to STARTERKIT_. * For example: * * original: theme_breadcrumb() * theme override: STARTERKIT_breadcrumb() * * where STARTERKIT is the name of your sub-theme. For example, the * zen_classic theme would define a zen_classic_breadcrumb() function. * * If you would like to override any of the theme functions used in Zen core, * you should first look at how Zen core implements those functions: * theme_breadcrumbs() in zen/template.php * theme_menu_item_link() in zen/template.php * theme_menu_local_tasks() in zen/template.php * * For more information, please visit the Theme Developer's Guide on * Drupal.org: http://drupal.org/node/173880 * * CREATE OR MODIFY VARIABLES FOR YOUR THEME * * Each tpl.php template file has several variables which hold various pieces * of content. You can modify those variables (or add new ones) before they * are used in the template files by using preprocess functions. * * This makes THEME_preprocess_HOOK() functions the most powerful functions * available to themers. * * It works by having one preprocess function for each template file or its * derivatives (called template suggestions). For example: * THEME_preprocess_page alters the variables for page.tpl.php * THEME_preprocess_node alters the variables for node.tpl.php or * for node-forum.tpl.php * THEME_preprocess_comment alters the variables for comment.tpl.php * THEME_preprocess_block alters the variables for block.tpl.php * * For more information on preprocess functions and template suggestions, * please visit the Theme Developer's Guide on Drupal.org: * http://drupal.org/node/223440 * and http://drupal.org/node/190815#template-suggestions */ /* * Add any conditional stylesheets you will need for this sub-theme. * * To add stylesheets that ALWAYS need to be included, you should add them to * your .info file instead. Only use this section if you are including * stylesheets based on certain conditions. */ /* -- Delete this line if you want to use and modify this code // Example: optionally add a fixed width CSS file. if (theme_get_setting('soundsoftware_fixed')) { drupal_add_css(path_to_theme() . '/layout-fixed.css', 'theme', 'all'); } // */ /** * Implementation of HOOK_theme(). */ function soundsoftware_theme(&$existing, $type, $theme, $path) { $hooks = zen_theme($existing, $type, $theme, $path); // Add your theme hooks like this: /* $hooks['hook_name_here'] = array( // Details go here ); */ // @TODO: Needs detailed comments. Patches welcome! return $hooks; } /** * Override or insert variables into all templates. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered (name of the .tpl.php file.) */ /* -- Delete this line if you want to use this function function soundsoftware_preprocess(&$vars, $hook) { $vars['sample_variable'] = t('Lorem ipsum.'); } // */ /** * Override or insert variables into the page templates. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("page" in this case.) */ function soundsoftware_preprocess_page(&$vars, $hook) { if ($vars['title'] == "Software for Audio and Music Researchers") { $vars['title'] = ''; } } /** * Override or insert variables into the node templates. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("node" in this case.) */ /* -- Delete this line if you want to use this function function soundsoftware_preprocess_node(&$vars, $hook) { $vars['sample_variable'] = t('Lorem ipsum.'); } // */ /** * Override or insert variables into the comment templates. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("comment" in this case.) */ /* -- Delete this line if you want to use this function function soundsoftware_preprocess_comment(&$vars, $hook) { $vars['sample_variable'] = t('Lorem ipsum.'); } // */ /** * Override or insert variables into the block templates. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("block" in this case.) */ /* -- Delete this line if you want to use this function function soundsoftware_preprocess_block(&$vars, $hook) { $vars['sample_variable'] = t('Lorem ipsum.'); } // */ /** * Custom pager module variables * */ function soundsoftware_preprocess_custom_pager(&$vars) { drupal_add_css(drupal_get_path('module', 'custom_pagers') .'/custom_pagers.css'); $node = $vars['node']; $pager = $vars['pager']; $nav = $vars['nav_array']; // new lines for the titles $nextTitle = isset($nav['next']) ? check_plain(db_result(db_query('SELECT title FROM {node} WHERE nid = %d',$nav['next']))) : ''; $prevTitle = isset($nav['prev']) ? check_plain(db_result(db_query('SELECT title FROM {node} WHERE nid = %d',$nav['prev']))) : ''; $vars['previous'] = !empty($nav['prev']) ? l("< Newer article: " . $prevTitle . "", 'node/'. $nav['prev']) : ''; $vars['key'] = t('@count of @count_total', array('@count' => ($nav['current_index'] + 1), '@count_total' => count($nav['full_list']))); $vars['next'] = !empty($nav['next']) ? l("Older article: " . $nextTitle . " >", 'node/'. $nav['next']) : ''; // comment out these 3 lines // $vars['previous'] = !empty($nav['prev']) ? l('‹ ' . t('previous'), 'node/'. $nav['prev']) : ''; // $vars['key'] = t('@count of @count_total', array('@count' => ($nav['current_index'] + 1), '@count_total' => count($nav['full_list']))); // $vars['next'] = !empty($nav['next']) ? l(t('next') . ' ›', 'node/'. $nav['next']) : ''; $vars['suggestions'][] = "custom-pager-{$vars['position']}"; $vars['suggestions'][] = "custom-pager-$node->type"; $vars['suggestions'][] = "custom-pager-$node->type-{$vars['position']}"; $vars['suggestions'][] = "custom-pager-$pager->pid"; $vars['suggestions'][] = "custom-pager-$pager->pid-{$vars['position']}"; }