Hey, "i'm back"
I've been off this project for a month and now that my client has noticed a "mistake" in the switcher...
http://www.lolalola.be/xcart/home.php
http://www.lolalola.be/xcart/home.php?cat=4 as you can see.... it does change the styles, according to the "parent - Id"
But as soon as you choose a product in any category " http://www.lolalola.be/xcart/product.php?productid=58&cat=46&page=1" it switches back to the default green style..... now ofcourse that is not what is meant to happen....
PHP Code:
<?php
if ( !defined('XCART_SESSION_START') ) { header("Location: ../"); die("Access denied"); }
$switchid = false;
if( $current_category['parentid'] > 0 ) {
/* Get array of all cats */
$all_cats = func_query("SELECT categoryid, parentid FROM xcart_categories");
/* Build 2-dim array of parent->child cats */
$all_cat_arr = array();
foreach($all_cats AS $_cat) {
$all_cat_arr[$_cat['parentid']][] = $_cat['categoryid'];
}
/* Get absolute parent */
$switchid = _get_absolute_parent($current_category['parentid'], $all_cat_arr);
}
if( !$switchid ){
$switchid = $current_category['categoryid'];
}
switch ($switchid) {
case '15':
$StyleSwitch = '<style type="text/css">';
$StyleSwitch .= 'body {background-image: url(http://www.lolalola.be/xcart/skin1/images/lolalayout/bg_15.gif);}';
$StyleSwitch .= '.background { background-image: url(http://www.lolalola.be/xcart/skin1/images/lolalayout/15.gif);}';
$StyleSwitch .= '</style>';
$smarty->assign('StyleSwitch', $StyleSwitch);
break;
case '54':
$StyleSwitch = '<style type="text/css">';
$StyleSwitch .= 'html body {background-image: url(http://www.lolalola.be/xcart/skin1/images/lolalayout/bg_54.gif); !important}';
$StyleSwitch .= '.background { background-image: url(http://www.lolalola.be/xcart/skin1/images/lolalayout/54.gif);}';
$StyleSwitch .= '</style>';
$smarty->assign('StyleSwitch', $StyleSwitch);
break;
default:
}
function _get_absolute_parent($catid, $all_cats) {
reset($all_cats);
foreach($all_cats AS $_parentcat=>$_children) {
if( in_array($catid, $_children) ) {
if($_parentcat == 0) {
return $catid;
}
return _get_absolute_parent($_parentcat, $all_cats);
}
}
/* else, failed */
return false;
}
?>
I've included the code that does work for the switch, but not 100% --> Can some please help me out... I know it is probably just one line of code, but I design, not develop
