Skip to main content
Feb
05
2013

Drupal 7 notes: node or page template by path

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
  }
?>