PHP - modificar el css dependiedo categoria

   
Vista:

modificar el css dependiedo categoria

Publicado por Ricardo (20 intervenciones) el 01/12/2008 04:40:23
Hola tengo 5 categorias , en donde cada categoria tiene otras subcategorias, esto esta elaborado en XCART solo que necesito modicar el CSS dependiendo de la seleccion de la categoria.

Como puedo realizar la modificación ? aqui presente algo del codigo
if ( !defined('XCART_SESSION_START') ) { header("Location: ../"); die("Access denied"); }

x_load('files');

#
# Functions definition
#

#
# This function builds the categories list within specified category ($cat)
#
function func_get_categories_list($cat=0, $short_list=true, $flag=NULL) {
global $current_area, $sql_tbl, $shop_language, $active_modules, $config, $xcart_dir;

$cat = intval($cat);

$all_categories = array();
$categories = array();
$subcategories = array();

$search_condition = array();

if ($flag == "root")
$search_condition[] = "$sql_tbl[categories].parentid='0'";
elseif ($flag == "level")
$search_condition[] = "$sql_tbl[categories].parentid='$cat'";
elseif ($flag == "current")
$search_condition[] = "$sql_tbl[categories].parentid IN ('0','$cat')";

if ($current_area == "C" || $current_area == "B") {
global $user_account;
$search_condition[] = "$sql_tbl[categories].avail='Y'";
$search_condition[] = "($sql_tbl[category_memberships].membershipid IS NULL OR $sql_tbl[category_memberships].membershipid = '$user_account[membershipid]')";
if ($flag == "all")
$sort_condition = " ORDER BY category";
else
$sort_condition = " ORDER BY $sql_tbl[categories].order_by, category";
} elseif (defined('MANAGE_CATEGORIES')) {
$sort_condition = " ORDER BY $sql_tbl[categories].order_by, $sql_tbl[categories].category";
}

if ($short_list) {
$to_search = "$sql_tbl[categories].categoryid,$sql_tbl[categories].parentid,$sql_tbl[categories].categoryid_path,$sql_tbl[categories].category,$sql_tbl[categories].avail,$sql_tbl[categories].order_by";
} else {
$to_search = "$sql_tbl[categories].*";
}

$join_tbl = '';
if ($current_area == "C" || $current_area == "B") {
$join_tbl .= " LEFT JOIN $sql_tbl[categories_lng] USE INDEX (PRIMARY) ON $sql_tbl[categories_lng].code='$shop_language' AND $sql_tbl[categories_lng].categoryid=$sql_tbl[categories].categoryid ";
$join_tbl .= " LEFT JOIN $sql_tbl[category_memberships] ON $sql_tbl[category_memberships].categoryid = $sql_tbl[categories].categoryid ";
$to_search .= ", IF($sql_tbl[categories_lng].categoryid IS NOT NULL AND $sql_tbl[categories_lng].category != '', $sql_tbl[categories_lng].category, $sql_tbl[categories].category) as category";
}

#
# Count the subcategories for "root" and "level" flag values
#
if ($flag == "level" || $flag == "root" || $flag == "current" || is_null($flag)) {
if ($current_area == "C" || $current_area == "B") {
$join_tbl .= " LEFT JOIN $sql_tbl[categories_subcount] USE INDEX (PRIMARY) ON $sql_tbl[categories_subcount].categoryid = $sql_tbl[categories].categoryid AND $sql_tbl[categories_subcount].membershipid = '$user_account[membershipid]' ";
$to_search .= ",$sql_tbl[categories_subcount].subcategory_count, $sql_tbl[categories_subcount].product_count";
} else {
$join_tbl .= " LEFT JOIN $sql_tbl[categories_subcount] USE INDEX (PRIMARY) ON $sql_tbl[categories_subcount].categoryid = $sql_tbl[categories].categoryid ";
$to_search .= ",MAX($sql_tbl[categories_subcount].subcategory_count) as subcategory_count, MAX($sql_tbl[categories_subcount].product_count) as product_count";
}

} elseif ($short_list) {
$to_search .= ",$sql_tbl[categories].product_count";
}

#
# Check category icons
#
if ($flag == "level" || $flag == "root" || $flag == "current" || is_null($flag)) {
$to_search .= ", $sql_tbl[images_C].image_path, $sql_tbl[images_C].image_x, $sql_tbl[images_C].image_y";
$join_tbl .= " LEFT JOIN $sql_tbl[images_C] ON $sql_tbl[categories].categoryid = $sql_tbl[images_C].id ";
}

if (defined('NEED_PRODUCT_CATEGORIES')) {
global $productid;
$_categories = func_query_hash("SELECT $to_search, $sql_tbl[products_categories].productid, $sql_tbl[products_categories].main FROM $sql_tbl[categories] $join_tbl LEFT JOIN $sql_tbl[products_categories] ON $sql_tbl[categories].categoryid=$sql_tbl[products_categories].categoryid AND $sql_tbl[products_categories].productid='$productid' AND $sql_tbl[products_categories].main != 'Y' GROUP BY $sql_tbl[categories].categoryid", "categoryid", false);
} else {
$_categories = func_query_hash("SELECT $to_search FROM $sql_tbl[categories] USE INDEX (am) $join_tbl ".(!empty($search_condition) ? "WHERE ".implode(" AND ", $search_condition) : "").(strlen($join_tbl) > 0 ? " GROUP BY $sql_tbl[categories].categoryid" : "")." ".$sort_condition, "categoryid", false);
}

if (!is_array($_categories) || empty($_categories))
return array("all_categories" => array(), "categories" => array(), "subcategories" => array());

foreach ($_categories as $k => $category) {
$category['categoryid'] = $_categories[$k]['categoryid'] = $k;

#
# Get the full path for category name
#
if ($flag == "all" || is_null($flag)) {
$path = explode("/", $category["categoryid_path"]);
$category_path = array();
foreach ($path as $catid) {
if (empty($_categories[$catid]))
break;
$category_path[] = $_categories[$catid]['category'];
}
if (count($category_path) != count($path))
continue;

$category["category_path"] = implode("/",$category_path);
unset($category_path);

}

$category['is_icon'] = !is_null($category["image_path"]);
$category["icon_url"] = func_get_image_url($k, 'C', $category["image_path"]);

$all_categories[$k] = $category;

if (($flag == "root" || $flag == "current" || is_null($flag)) && $category["parentid"] == 0)
$categories[$k] = $category;

if (($flag == "level" || $flag == "current" || is_null($flag)) && $category["parentid"] == $cat)
$subcategories[$k] = $category;

}
unset($_categories);

Me peudes ayudar?

gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:modificar el css dependiedo categoria

Publicado por Reaven (48 intervenciones) el 02/12/2008 11:56:30
Nunca he trabajado con xcart.... pero bueno haciendonos una idea de lo qeu quieres hay varias cuestiones a tener en cuenta, por ejemplo a la template como le assignas los css?... Lo mas logico seria que te generaras una variable y la pasaras a la template y en funcion de esa variable el item html cargara un css u otro.... O hacer el paso del nombre del css desde php y cargarlo en xcart.... Aqui no solo cuenta el php, tambien deberiamos saber como cargas los css....
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar