3

Is there a simple way to create a custom template in a theme for a custom page in Drupal 7.

I've tried all of the normal conventions:

page-custom_page_name.tpl.php page-custom--page--name.tpl.php etc.

None seem to be working. Help would be much appreciated!

2 Answers 2

11

Drupal automatically provides path based overrides; so if the path to your custom page is, say, 'custom/page/path' you can create a template file called 'page--custom--page--path.tpl.php`, which will only be used for that page.

Remember to clear Drupal's caches each time you add a new template file or the theme registry won't pick it up.

1
  • For URL like myrally.com/trade the custom template will be page--trade.tpl.php ?
    – deb0rian
    Commented Apr 8, 2014 at 8:14
0

Using the alias or 'custom/page/path' as suggested didn't work for me.

According to the Drupal documentation:

https://www.drupal.org/node/1089656

The internal/path is not the alias it's the node's ID.

...the Drupal path is not any of its aliases: there is one and only one Drupal path for a page. For the examples "http:// www.example.com/node/1/edit" and "http:// www.example.com/mysitename?q=node/1/edit", the Drupal path is node/1/edit, and its components are "node", 1, and "edit".

So in my case a basic page would be custom themed by page--node--1234.tpl.php where 1234 is the node id.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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