X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Changing Individual Category Background Colours (https://forum.x-cart.com/showthread.php?t=44613)

joannet 01-05-2009 04:49 PM

Changing Individual Category Background Colours
 
Hi,

I would like to change the background colours of 3 category headings in the categories.tpl. Each of these individual categories are to be different colours, and the remaining categories are to stay the original colour.

The original code for this template was:

{if $config.General.root_categories eq "Y"}
{foreach from=$categories item=c}
<div><a href="home.php?cat={$c.categoryid}" class="menulink">{$c.category}</a></div>
<div style="height:3px;"><img src="{$ImagesDir}/spacer.gif" width="10" height="3" alt="" /></div>
{*<table width="200" cellpadding="0" cellspacing="0" border="0" height="1"><tr><td><img src="{$ImagesDir}/spacer.gif" border="0" width="1" height="1" alt="" /></td></tr></table>*}
{/foreach}
{/if}

I have changed it to the following with no success:

{if $config.General.root_categories eq "Y"}
{foreach from=$categories item=c}
{if $categories[cat_num].categoryid == "281"}
<div><a href="home.php?cat=281" class="menulink1">Category A</a></div>
<div style="height:3px;"><img src="{$ImagesDir}/spacer.gif" width="10" height="3" alt="" /></div>
{/if}
{if $categories[cat_num].categoryid == "284"}
<div><a href="home.php?cat=284" class="menulink2">Category B</a></div>
<div style="height:3px;"><img src="{$ImagesDir}/spacer.gif" width="10" height="3" alt="" /></div>
{/if}
{if $categories[cat_num].categoryid == "280"}
<div><a href="home.php?cat=280" class="menulink3">Category C</a></div>
<div style="height:3px;"><img src="{$ImagesDir}/spacer.gif" width="10" height="3" alt="" /></div>
{/if}
{if $categories[cat_num].categoryid ne "281" || $categories[cat_num].categoryid ne "284" || $categories[cat_num].categoryid ne "280"}
<div><a href="home.php?cat={$c.categoryid}" class="menulink">{$c.category}</a></div>
<div style="height:3px;"><img src="{$ImagesDir}/spacer.gif" width="10" height="3" alt="" /></div>
{/if}

{*<table width="200" cellpadding="0" cellspacing="0" border="0" height="1"><tr><td><img src="{$ImagesDir}/spacer.gif" border="0" width="1" height="1" alt="" /></td></tr></table>*}
{/foreach}
{/if}


I have added new classes to skin1.css (menulink1, menulink2, menulink2) which change the background colour.

Can anybody please advise what I'm doing wrong?

Thanks

ARW VISIONS 01-05-2009 05:16 PM

Re: Changing Individual Category Background Colours
 
you are over complicating it.

do something like this.

{if $config.General.root_categories eq "Y"}
{foreach from=$categories item=c}
<div><a href="home.php?cat={$c.categoryid}"
{if $c.categoryid eq "281"}class="menulink1"{elseif $c.categoryid eq "284"}
class="menulink2"{elseif $c.categoryid eq "280"}class="menulink3"{else}
class="menulink"{/if}
>{$c.category}</a></div>
<div style="height:3px;"><img src="{$ImagesDir}/spacer.gif" width="10" height="3" alt="" /></div>
{*<table width="200" cellpadding="0" cellspacing="0" border="0" height="1"><tr><td><img src="{$ImagesDir}/spacer.gif" border="0" width="1" height="1" alt="" /></td></tr></table>*}
{/foreach}
{/if}

joannet 01-05-2009 06:32 PM

Re: Changing Individual Category Background Colours
 
Hi Ashley,

Worked perfectly!

Thanks heaps for your expertise and efficient response:)

ARW VISIONS 01-05-2009 08:42 PM

Re: Changing Individual Category Background Colours
 
no problem. glad to help.

Thedae2k 01-07-2009 12:35 AM

Re: Changing Individual Category Background Colours
 
Look at you bring the new moderator muscle to the table Ashley...I just used this on something and I went about it a much more difficult way and I just changed to your way. thanks


All times are GMT -8. The time now is 02:56 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.