3

I can't seem to use a unique page--xxxxxxx.tpl.php for a specific page.

I created a "page" content, filled it in, and gave it a path alias. Let's say: "mypage/mycontent". Then I created a page--mypage--mycontent.tpl.php file in my theme's root. Instead of using it, my page.tpl.php is being used.

I was under the impression that Drupal 7 automatically searches for template suggestions using the format of page--path.tpl.php, is this incorrect? Do I need to include specific code in my template.php file first? I did try clearing the theme cache, btw and that didn't make a difference.

Free Radical
  • 2,052
  • 1
  • 21
  • 35
user985219
  • 243
  • 1
  • 2
  • 10

2 Answers2

2

If it's just a node, try to rename your template file to page--node--NID.tpl.php and then flush the cache, also don't forget to replace NID with the nid of this node to be something like page--node--11.tpl.php :)

Hope this works... Muhammad

Muhammad Reda
  • 26,379
  • 14
  • 93
  • 105
  • There is no need to rename (and it may not always be possible, not all paths points to nodes). The file name `page--mypage--mycontent.tpl.php` will work, provided all cached data is cleared out of the way. – Free Radical Sep 02 '13 at 09:28
1

Your impression is correct, and page--mypage--mycontent.tpl.php (i.e. the one you've already tried) is the correct file name to use to override the page.tpl.php for a page with that specific path "mypage/mycontent". You don't need to change anything else.

However, in addition to clearing Drupal's cache, you also need to clear the browser's cache. In most browsers, including Firefox and MSIE, you do this by holding down the SHIFT key while reloading the page. Without clearing the browser's cache, you will not be able to view your template suggestion in the browser.

Free Radical
  • 2,052
  • 1
  • 21
  • 35