Sunday, 4 September 2011

Create different page templates depending on the current path in drupal

In drupal default template is page.tpl.php.
Drupal check the available template for following order it use the first available template for the current page.
 
1. http://www.mysite.com/node/22
This URL is encountered drupal will check for available templates in the following order.

page-node-22.tpl.php

page-node.tpl.php

page.tpl.php

2. http://www.mysite.com/node/22/edit 
Similarly

page-node-edit.tpl.php

page-node-22.tpl.php

page-node.tpl.php

page.tpl.php

3.  http://www.mysite.com/calendar


page-calendar.tpl.php

page.tpl.php


If you are using URL alias like  http://www.mysite.com/node/2 is http://www.mysite.com/about
To check alias for node in URL aliases->list


Following order is used to check for templates.

page-node-2.tpl.php

page-node.tpl.php

page.tpl.php
 

0 comments:

Post a Comment