Return to Snippet

Revision: 22543
at January 14, 2010 18:26 by zachharkey


Updated Code
/**
 * 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.
 */
function genesis_custom_preprocess_page(&$vars, $hook) {  
   // Add page template suggestions based on path alias.
   $alias = drupal_get_path_alias($_GET['q']);
   if ($alias != $_GET['q']) {
     $template_filename = 'page';
     foreach (explode('/', $alias) as $path_part) {
       $template_filename = $template_filename . '-' . $path_part;
       $vars['template_files'][] = $template_filename;
     }
   }
}

Revision: 22542
at January 14, 2010 18:25 by zachharkey


Initial Code
/**
 * 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.
 */
function genesis_custom_preprocess_page(&$vars, $hook) {  
   // Add page template suggestions based on path alias.
   $alias = drupal_get_path_alias($_GET['q']);
   if ($alias != $_GET['q']) {
     $template_filename = 'page';
     foreach (explode('/', $alias) as $path_part) {
       $template_filename = $template_filename . '-' . $path_part;
       $vars['template_files'][] = $template_filename;
     }
   }
}  

Initial URL


Initial Description


Initial Title
Add Drupal page template suggestions based on path alias.

Initial Tags
textmate, drupal

Initial Language
PHP