Not for official support
We do not provide technical support in this forum.
If you want to contact our customer support, please use our support form.
You are not logged in.
How can I make different style (background) for each item list in category tree?
Thank you.
Offline
Do you want random colors to be assigned to category tree items or to bind a specific color to each category?
Offline
I want specific color for each category item.
Thank you.
Offline
In file published/SC/html/scripts/core_functions/category_functions.php find function catGetCategoryCompactCList and add the following code
$category_colors = array (
1135 => 'red',
1134 => 'green',
1105 => 'blue'
);
$colored_categoryIDs = array_keys ($category_colors);
foreach ($res as $i => $category){
if (in_array ($category['categoryID'], $colored_categoryIDs)){
$res[$i]['color'] = $category_colors[$category['categoryID']];
}
}before line
return $res;
Write the desired categoryIDs and colors in the above code separated by commas.
In file published/SC/html/scripts/templates/frontend/category_tree.html replace line
<span class="bullet"> </span><a href='{$_category_url}'>{$categories_tree[i].name|escape:'html'|default:"(no name)"}</a>with
<span class="bullet"> </span><a href='{$_category_url}'{if $categories_tree[i].color} style="color: {$categories_tree[i].color};"{/if}>{$categories_tree[i].name|escape:'html'|default:"(no name)"}</a>Offline
It works, thank you for your answer.
I have made some changes because I want different background for each categories and subcategories, but I would not have succeeded without your advice.
Offline