Posted By

zachharkey on 01/14/10


Tagged

textmate drupal templatephp preprocess


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

Onfire60
tronx


Add Drupal page template suggestions based on path alias.


 / Published in: PHP
 

  1. /**
  2.  * Override or insert variables into the page templates.
  3.  *
  4.  * @param $vars
  5.  * An array of variables to pass to the theme template.
  6.  * @param $hook
  7.  * The name of the template being rendered.
  8.  */
  9. function genesis_custom_preprocess_page(&$vars, $hook) {
  10. // Add page template suggestions based on path alias.
  11. $alias = drupal_get_path_alias($_GET['q']);
  12. if ($alias != $_GET['q']) {
  13. $template_filename = 'page';
  14. foreach (explode('/', $alias) as $path_part) {
  15. $template_filename = $template_filename . '-' . $path_part;
  16. $vars['template_files'][] = $template_filename;
  17. }
  18. }
  19. }

Report this snippet  

You need to login to post a comment.