I tried using a custom template file for my theme, but using page--testpage.tpl.php (where testpage is the path alias for the page being shown) doesn't work. It just works with page--node--47.tpl.php

How could I fix it?


Read Drupal 7 Template (Theme Hook) Suggestions

A theme hook suggestions is an alternate template (.tpl.php) file that you have created to override the base or original template file.

The list of suggested template files is in order of specificity based on internal paths. One suggestion is made for every element of the current path, though numeric elements are not carried to subsequent suggestions. For example, "http://www.example.com/node/1/edit" would result in the following suggestions:





Read Theming Drupal 6 and 7

If you still want to alter the suggestions its possible with template_preprocess_page

function template_preprocess_page(&$variables) {
  $variables['theme_hook_suggestions'][] = "page--type--" . $vars['node']->type;
  // likewise you can do 
  // $variables['theme_hook_suggestions'][] = "page".GET-URL-ALIAS-HERE;

From your comments, it looks like you're using Drupal 6. In that case, use a single hypen (not a double) in the name of your template file. I.e.: page-testpage.tpl.php instead of page--testpage.tpl.php.

(Use the double hyphen syntax for Drupal 7.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.