Skip to main content

Drupal 7 notes: node or page template by path

Posted on: Tuesday, 5 February 2013 @ 6:55pm
Blatting about
More specifically

Because I always seem to manage to completely forget how to do something this basic.

template.php in theme_preprocess_page(&$variables) or theme_preprocess_node(&$variables)

<?php
  $path = drupal_get_path_alias();

  if (strpos($path, 'part_of_url') !== false) {
    $variables['theme_hook_suggestion'] = 'page__whatever'; // or node__whatever if using in a node preprocess
  }
?>

 

No comments yet

Add new comment

The content of this field is kept private and will not be shown publicly.