theming
Fun with Theme Switching
Posted June 17th, 2008 by JodyUPDATE: CODE REWORKED THANKS TO CHX
<?php
/**
* Implementation of hook_menu (D5 code)
*/
function SOMEMODULE_menu($may_cache) {
if (!$may_cache) {
if ($theme = $_GET['theme']) {
$themes = list_themes();
if (isset($themes[$theme])) {
$GLOBALS['custom_theme'] = $theme;
}
}
}
}
?>With this you can amuse yourself by browsing to /node/1?theme=marvin
I was thinking this could actually be useful- for example you could make an all xml theme and have Flash get data from path/to/page?theme=xml_theme
File-Based Content Templates
Posted April 10th, 2008 by JodyJohn Forsythe recently posted that Contemplate is one of the most favorited modules on his DrupalModules.com site, attributable to the learning curve of creating template files.
With no offense to Jeff Robbins who created this very clever module, I've never been a big fan of Contemplate. I don't like it when people store code and markup in the database because it makes it impossible for me to find where their markup comes from when I search the files. It also puts it out of the reach of version control, and creates the possibility of a white-screen situation which can only be fixed by going into the database directly.
But contemplate fills a real void created by the difficulty in per-field theming in Drupal 5. I posted about my method of handling per-field theming in content types recently and have been refining that method since. The purpose of my technique is to allow per-field custom theming without requiring additional work every time a new field is added. Essentially you print out any fields you would like to custom theme, and then you loop through all the other fields and print them all out in the order and with the 'Display Fields' settings as set in CCK. Although this method requires additional setup up front, it pays off when you add new fields (or modules that add new node content of their own) and you don't have to readjust your template (or contemplate).



