1

I have created the custom template page-org.tpl.page in the Zen theme, and I want to include this custom template file in the menu calling; when the user clicks on the Org link it should use the template file page-org.tpl.page.
How can I do that?

  • Welcome on Drupal Answers. To which Drupal version are you interested? Different Drupal versions use different template names; without to know to which Drupal version are you interested, it is difficult to give the correct answer. – kiamlaluno May 3 '11 at 14:42
  • Possible duplicate: Page template suggestions are not working. – kiamlaluno May 3 '11 at 20:59
1

Output your $vars in the theme so you can see your candidate templates.

EDIT: I thought you were looking for a content type solution when I first read this :)

Here's a gotcha: you have to have master templates before you can have ones within it. For example content-field-field_my_content.tpl.php will not work until content-field.tpl.php is in place in the theme.

You may need to place some PHP in your template.php within preprocess_page()

if(!arg(2)) $variables['template_files'][] = 'page-node_'.$variables['node']->type;

(The arg2 check helps make sure this doesn't happen on edit pages.)

Lastly, you can also accomplish this with Context Layout.

|improve this answer|||||
0

The page template must be named: page-node-XX.tpl.php.

Replace XX by the node id of the page.

|improve this answer|||||
0

As reported in the source code of template_preprocess_page():

// Build a list of suggested template files in order of specificity. 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:
//
// page-node-edit.tpl.php
// page-node-1.tpl.php
// page-node.tpl.php
// page.tpl.php

Similar comment is contained in the code source of theme_get_suggestions(), which is the function called from template_preprocess_page() in Drupal 7:

//One suggestion is made for every element of the current path,
// though numeric elements are not carried to subsequent suggestions. For
// example, for $base='page', http://www.example.com/node/1/edit would result
// in the following suggestions and body classes:
//
// page__node              page-node
// page__node__%           page-node-%
// page__node__1           page-node-1
// page__node__edit        page-node-edit

Supposing that the link takes to http://example.com/links/org, then the template file for that page should be page-links-org.tpl.php or page-org.tpl.php for Drupal 6, and page--links--org.tpl.php or page--org.tpl.php for Drupal 7.

|improve this answer|||||

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.