Search
Tags for Drupal 6 Different page templates depending on URL aliases

Drupal 6 Different page templates depending on URL aliases

Place this code in your template.php file if you want u use different templates for the same code.

Create a template named page-SOMETING-tpl.php
Create a url alias node/NID SOMETHING

function phptemplate_preprocess_page(&$vars) {
  if (module_exists('path')) {
    $alias = drupal_get_path_alias(str_replace('/edit','',$_GET['q']));
    if ($alias != $_GET['q']) {
      $suggestions = array();
      $template_filename = 'page';
      foreach (explode('/', $alias) as $path_part) {
        $template_filename = $template_filename . '-' . $path_part;
        $suggestions[] = $template_filename;
      }
    $vars['template_files'] = array_merge((array) $suggestions, $vars['template_files']);
    }
  }
}

Great thanks


Hi Rob,

Thanks for this comment.
I was looking for it for a while.

Comment viewing options
Select your preferred way to display the comments and click "Save settings" to activate your changes.
Post new comment
The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.