By kvarnelis on
Is there a way to select a theme based on node type and/or path?
The sections module seems to be ideal for this task, but it also seems to have been abandoned.
I've read the Drupal handbooks on this, but as I've found in two years of working with Dru, hacking of any sort (such as coping page template files, etc.) is generally a bad idea since upgrades tend to break it.
I'd much rather find a module that could just assign a theme based on path.
Is there anything obvious I am missing here?
Comments
Module?
I don't know that there is a module for it, but PHPTemplate in Drupal 5 supports path-based page.tpl.php files. So you can have:
page-blog.tpl.phporpage-taxonomy-term-1.tpl.php. See http://drupal.org/node/104316 for details.In that case, your separate page-path.tpl.php files would have different HTML.
I just implemented some theme-switching for the MySite module: http://drupal.org/node/124408. It wouldn't be very hard to write a small module that implements theme switching based on a set of rules. If you wanted those rules to be GUI-configurable, it would be a little more complex, but still fairly simple.
They key is setting the global variable $custom_theme. In MySite, the code looks like this:
We pull the user's settings and check to see that they are valid, if so, we reset the $custom_theme variable. Currently, I do this in hook_menu, though hook_init might be a better choice. See http://api.drupal.org/api/5/function/hook_init.
--
http://ken.blufftontoday.com/
http://new.savannahnow.com/user/2
Search first, ask good questions later.
Simple non-hack approach
Given a content type, say 'page', copy node.tpl.php to node-page.tpl.php. In general, replace 'page' with the content type name you want themed differently. Change to your hearts content.
One way to avoid breaking your changes is to first completely copy your theme to an new name and work with your private copy, that way if the official theme is updated, your changes are not overwritten.
Try the taxonomy_theme
Try the taxonomy_theme module, maybe that's what you need.
--
I'm from Hong Kong. My profile shows Thailand because Hong Kong was not available from the country list.
d'oh!
Well that did the trick.
I didn't realize that taxonomy theme was able to theme based on the path or nodetype.
The name is a bit misleading in that respect.
Perfect! The problem was that I wanted a different theme on a CCK input page and this did the trick.
Thank you.
Glad it helps ! :) -- I'm
Glad it helps ! :)
--
I'm from Hong Kong. My profile shows Thailand because Hong Kong was not available from the country list.
Still the best way to change the theme used for "page" nodes ?
Hi,
Is it still the best way to change the theme used for "page" node type ?
thanks.