0

I have a requirement to apply template to a specific page and not to the pages following the same url pattern. For example I have a page with the path /asia. I also have pages with the paths /asia/india, /asia/china etc. I would like to create a template which applies only for /asia and not for other paths. I created the template file page--asia.tpl.php but it is getting applied for /asia/india and /asia/china as well. Is there a way to specifically map the template to this specific path?

2

To overwrite Drupal defalut suggestion, You can make your own suggestion for template.

In your case you have defined a menu called asia for that specific template is required, to implement this use this code

 **
 * Implementation of hook_preprocess_HOOK().
 */
function mymodule_preprocess_page(&$variables){
  if(isset($variables['asia']) && arg(1) == '')
    $variables['theme_hook_suggestions'][] = 'page__asiapage';
}

create a tpl file in theme called page--asiapage.tpl.php, it will work.

  • 1
    Thanks Ramesh! This worked.I used the condition if(arg(0)=='asia' && arg(1)=='') instead of the one specified above. – Bhuvana Feb 4 '14 at 10:23
0

Follow the below points:

  1. Create a file with the name "page--node--nodeid.tpl.php" template.
  2. Replace nodeid with the node you want to theme.
  3. Clear the performance.
  • Thanks for the reply Astha! This solution doesn't work in my case since the page is an empty pagecallback and not a node. – Bhuvana Feb 4 '14 at 10:36

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.