By sethstevenson on
I've seen this done in every version but 7.x.
I was thinking I could make a template for just my article nodes using "page-article.tpl.php" or "page--article.tple.php" but neither seems to work.
I've seen this done in every version but 7.x.
I was thinking I could make a template for just my article nodes using "page-article.tpl.php" or "page--article.tple.php" but neither seems to work.
Comments
Try using __
Try using __ (double underscore) instead of - or -- and let me know.
See http://drupal.org/node/224333#theme_hook_suggestions_2.
That seems on the right track
That seems on the right track but that is specific to node template files which I can currently do with something like "node--article.tpl.php". However I would like to also use a different page template for different content types like "page--article.tpl.php".
I ended up getting it to work
I ended up getting it to work with this
My main mistake was that in the documentation (http://drupal.org/node/224333#theme_hook_suggestions_2) they reference "$node->type" rather than "$vars['node']->type". Of course the name "$vars" is relative to your template_preprocess_page function.
All's well
All's well that ends well, as Shakespeare would say ;c)
...
I updated the docs, since theres no variable assignment it really should be
$variables['node']->type;in those docs (the example assumed$node = $variables['node']->type;).http://drupal.org/update/modules/6/7#theme_hook_suggestions_2
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
Careful resetting the 'theme_hook_suggestions' key
Thanks to everyone for your help here, came across this looking for a solution to this very issue and the above code solved when applied to template_preprocess_page, however I came across one caveat. Resetting 'theme_hook_suggestions' like this:
Can wipe out already existing suggestions [for example page--front.tpl.php]
Perhaps a check to see if the key already exists and is an array would be more prudent:
dashes vs. underscores: 2-2 (?)
Do I notice correctyly that in the template function we have to use underscore's, whilst in the actual file name we should use dashes?!
Yes.
Yes.
Contact me to contract me for D7 -> D10/11 migrations.