Another way of switching templates at run time could work like this (a tad sketchy, but placing the code as I suggested earlier in includes/init_includes/init_templates.php) - there could be several ways to do this but this is just one:
Code:
// template directory/folder name = array of category ids (cPath) that are to use that template
// also set the template directory names
$mens = array(1,2,4,5,8);
$mens['template_dir'] = 'mens';
$womens = array(3,6,7,9);
$womens['template_dir'] = 'womens';
$kids = array(10,11,12);
$kids['template_dir'] = 'kids';
// put all the templates listed above together in an array
$templates = array($mens, $womens, $kids);
// find the appropriate template to use
// loop through all the template dirs
for($i=0; $i < count($templates); $i++) {
if($template_dir != '') {
break;
}
// loop through all the category ids (cPath)
for($i2=0; $i2 < count($templates[$i]); $i2++) {
// if the current cPath we're looking at matches the cPath that the visitor is browsing, set the current template we're looking at as the template to use
if($templates[$i][$i2] == $_GET['cPath']) {
$template_dir = $templates[$i]['template_dir'];
break;
}
}
}
Bookmarks