Let me preface this by saying I've searched drupal.org for this question/answer, and maybe I missed it, but I've not seen what I need out there.

We are building a new site about college sports, and one of the requirements is that we have different themes based on the team. In other words, if someone is reading a story about Auburn football, we want the theme to be built around Auburn's colors and mascot. If you know college sports fans, you know how big a deal this is, and how important it is to get Auburn's theme instead of Alabama's on that page.

Now, I've looked around for ways to do this, and the things I've seen are close to what we need, but not quite. Instead of individual files of auburn-page.tpl.php, alabama-page.tpl.php, etc, we'd like to make complete themes, because we already have some, it will be easier on the designers, and it makes things more customizable and compartmentalized. I've tried this with existing drupal themes and code based on what I've found here, creating a theme called "master" that will call other themes based on a taxonomy value viz:


/**
 * This snippet loads up a different page-termname.tpl.php layout 
 * file based on the taxonomy term of the node. 
 *
 * For use in a page.tpl.php file.
 *
 * This works with Drupal 4.7
 */

if ($is_front) {
  include('../bluemarine/page.tpl.php');
  return;
}

/* load up the taxonomy terms for this node and page */

$terms = taxonomy_node_get_terms($node->nid);
rsort($terms);

/**
 * Check to see if the taxonomy term matches your query and load
 * a custom page.tpl.php layout file 
 */

if ($terms[0]->name == 'Auburn') {
   include '../voodoo_dolly/page.tpl.php'; 
   return;
}

/*If the taxonomy term name doesn't match, load the page-default.tpl.php */

else {include '../fern/page.tpl.php';
  return;}

Unfortunately, this leads to things like this error message:

details
Type php
Date Friday, January 5, 2007 - 14:41
User admin
Location http://localhost/SEC/
Referrer http://localhost/SEC/admin/themes
Message include(../bluemarine/page.tpl.php) [function.include]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/SEC/themes/master/page.tpl.php on line 13.
Severity error
Hostname ::1

So it can't find the appropriate filepath for the theme. Am I missing a value in a global variable? I've tried a lot of things, and I'm stumped.

Thanks,

Richard

Comments

magico’s picture

(subscribe)

anindita.b@druidendo.com’s picture

You can also try using ‘hook_custom_theme()'. Here is an example.

Duplika’s picture

Have you tried the Taxonomy Theme module?
--
Duplika | http://www.duplika.net

rbburton’s picture

*slaps forehead* Thanks!

Man, how did I miss that? I guess I did miss something obvious.

Richard Burton

lahoussaine’s picture

You can use also this one
http://drupal.org/project/content_theme

sharif.tanveer’s picture

I just seen somewhere in Drupal website & it really works right out of the box- www.drupal.org/project/themekey

Most of you probably want it to make a fancy front page & all the layout/features for rest of the site.

I just lost that buddy name who first mention that module name, but thanks anyway :)

manishmore’s picture

for theme-switching based on language . I have used this module and its built so perfectly so can't have better then ThemeKey .