Hi All,
I'm about to start a project which requires a few different page layouts. The site will have pages like About Us, Our Services, a FAQ and a News page. Probably about 8-10 static pages in all plus news nodes. Some of these pages will require a different layout than the standard layout. The front page will also need a special layout.
What is the best practice in Drupal for making different template files? What do people do? I can think of a few ways but I've never done this before. I don't think just block visibility will be enough.
1. Create different content types for the pages that require special layout. eg have Page and Page_2col, narrow_page, etc.
2. Just use the node id's of the pages. This seems hard to maintain to me because in a year it may hard to find the template for the About Us page if they are all named after node 11, node 37, etc.
3. Any other ways?
Thanks for your help.
Andrew
Comments
_
There's several ways to approach this. Probably the most common though would be either with different page-tpl.php template files or with the panels module (or a combination of both). Drupal will detect multiple page template files based on internal path by default, but you can setup other criteria if necesary. See http://drupal.org/node/190815#page-suggestion for more info.
Thanks for the reply. I
Thanks for the reply.
I thought about doing it by node ID. So just page-node-7.tpl.php but it just occurred to me that it wouldn't be particularly easy to maintain in the future because the filenames aren't really descriptive and a theme change will then involve changes to say 5 page.tpl.php files instead of just 1. I guess I might add some template suggestions in template.php and use a function to map node-id to template file so something like.
page-narrow.tpl.php
page-multicol.tpl.php
page.tpl.php
and have a function that says node ids 1,5 and 7 use page-narrow.tpl.pgp node 6 uses page-multicol.tpl.php, etc.
Thanks for your help.
_
You can add code to template.php to have your page templates be based on whatever you want (node title, path alias, taxonomy, whatever). see http://drupal.org/node/46006 for some examples and http://drupal.org/node/223440 for how.
You get this question a lot.
You get this question a lot. Perhaps it would be worth while to make a collection of resources saved to a text file and copy and paste it. There is a lot of really good information for people new to Drupal out there on the web but it's something hard to find.
I would really like to add that a lot of people use the composite module to create layouts too. http://drupal.org/project/composite
_
Composite does have its place, but I wouldn't call ~1600 sites 'a lot' -- especially when compared to panels' 26k sites.
=-=
may also be of benefit to watch this: http://acquia.com/community/resources/acquia-tv/tips-and-tricks-drupal-t... 90 minutes of themeing explaination