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.

#1 2012-02-16 08:45

itlab
Member

category tree items

How can I make different style (background) for each item list in category tree?

Thank you.

Offline

 

#2 2012-02-16 09:25

rat
Administrator

Re: category tree items

Do you want random colors to be assigned to category tree items or to bind a specific color to each category?


Be careful what you wish for — you might get it.

Offline

 

#3 2012-02-16 09:45

itlab
Member

Re: category tree items

I want specific color for each category item.

Thank you.

Offline

 

#4 2012-02-17 00:34

rat
Administrator

Re: category tree items

In file published/SC/html/scripts/core_functions/category_functions.php find function catGetCategoryCompactCList and add the following code

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

Code:

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

Code:

<span class="bullet">&nbsp;</span><a href='{$_category_url}'>{$categories_tree[i].name|escape:'html'|default:"(no name)"}</a>

with

Code:

<span class="bullet">&nbsp;</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>

Be careful what you wish for — you might get it.

Offline

 

#5 2012-02-17 04:38

itlab
Member

Re: category tree items

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

 

Board footer

Powered by PunBB