1
votes

I'd like to organize my Drupal themes like this:

[themeDir]/templates/[contentType]/node.tpl.php
[themeDir]/templates/[contentType]/page.tpl.php
[themeDir]/templates/[contentType]/html.tpl.php

You'll note that the template files are using the default names, not prefaced with the content type names. This way I can drop a folder into my theme, containing a set of templates I'd like to use for that content-type.

I've tried most of the methods of adding template suggestions in various template.php process functions, but can't seem to sort out the proper way to do this. Can it even be done?

I'd love some feedback. How slick would it be if Drupal 7 themes could be developed like this? Is it even possible?

Thanks in advance. Cheers!

1

1 Answers

0
votes

Are you aware of Drupal's template naming convention? You could also structure your templates within the templates directory. node.tpl.php is the default one for nodes. When you have a content type with a template you'll have to name it node--{type}.tpl.php for Drupal to pick it up. It's good practise to keep your templates directory structured with subdirectories but that's optional. As long as they reside in the templates directory Drupal will search the naming convention.

Now as for the default ones (html.tpl.php, page.tpl.php, node.tpl.php, etc...), they are considered Master templates, you could put those in a subdir system or default but this is also optional. Then for a content type ex: Article it's recommended to use a subdir article & follow the name convention for your node which would give you article/node--article.tpl.php. More subdirs as views, regions are also often being used.

More insights regarding template naming conventions can be found at Drupal.org's Drupal 7 Template Suggestions