2

I create a module and implement hook_menu():

function mymodule_menu(){
  $items['mymodule/list']=array(/*...*/);
  return $items;
}

then I create a theme and create page.tpl.php and page--mymodule-list.tpl.php at the same directory.

now I can access http://localhost/?q=mymodule/list, but it use page.tpl.php to render the page, instead of page--mymodule-list.tpl.php.

How should I do to make it render the page with page--mymodule-list.tpl.php?

  • Have you cleared the caches since adding your template file? And do you have a copy of the core page.tpl.php in your theme as well? – Clive Nov 27 '12 at 10:11
  • @Clive Yes, I have cleared the caches. And I found if I rename page--mymodule-list.tpl.php to page--mymodule.tpl.php, it work fine. – solomon_wzs Nov 27 '12 at 10:14
  • this is may due to admin theme. – monymirza Nov 27 '12 at 11:07
1

The 'rules' for the page.tpl.php template suggestions state you need to substitue each / in the page for 2 dashes, so your template file needs to be called:

page--mymodule--list.tpl.php

Remember to the clear the cache again once you've made the change

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.