For a site I'm working on, I wanted the theme to change when you change the topic. Now, this has been discussed before and the
Chameleon hack was developed as a result.
However, when all you need are a few color changes, there's a simpler solution that doesn't require any changes to Geeklog's core code.
This relies on the fact that you can use PHP in a theme's header.thtml file. To keep things readable, PHP code can also be added to the functions.php file that's part of every theme, so that you could add a function to that file and then simply call it from header.thtml.
So here's a simplified version of what I did:
In the theme's functions.php, add a function like this:
Text Formatted Code
function theme_emitCSS ()
{
global $topic;
switch ($topic) {
case 'GeekLog':
$color = 'red';
break;
case 'General':
$color = 'green';
break;
default:
$color = 'black';
break;
}
$retval = '<style type="text/css">' . LB
. '.current-color {' . LB
. ' color: ' . $color . ';' . LB
. ' background-color: white;' . LB
. '}' . LB
. '</style>' . LB;
return $retval;
}
This function simply checks what the current topic is and then emits CSS for a class called 'current-color', setting the foreground color accordingly.
All you have to do now is to add a call to that function in your theme's header.thtml like this:
Text Formatted Code
<head>
...
<?php theme_emitCSS (); ?>
</head>
and then use
class="current-color"
wherever you need it, e.g. in the blockheader.thtml template file.
This can be extended to emit CSS using background images and other, more complicated CSS rules. You can also check what the current PHP file is (using
$HTTP_SERVER_VARS['PHP_SELF']
, after adding
$HTTP_SERVER_VARS
to the list of global variables for that function) to select colors for Geeklog's calendar, links section, etc.
Hope it helps someone ...
bye, Dirk