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 the background color based on Category (https://forum.x-cart.com/showthread.php?t=54616)

minfinger 07-15-2010 06:46 AM

Changing the background color based on Category
 
For example in my Product List we have male and female puppies.
http://littlepuppiesonline.msidesigns.com/All-Little-Puppies/

I'm not hung up on it, but it would be great to be able to change the background color of each dogs listing based on their member ship to the Male or Female Category. Cat 10 for Male and 8 for Female?

Is this possible to set it up in the template as well as the Css?

Shamun 07-15-2010 12:08 PM

Re: Changing the background color based on Category
 
Find the background div and the proper variable and do something like:

{if $cat eq '10'}
<div id="special div for males">
{elseif $cat eq '8'}
<div id="special div for females">
{else}
<div id="standard div for the rest of the website">
{/if}

minfinger 07-15-2010 12:21 PM

Re: Changing the background color based on Category
 
Thanks Tal. I figured it was something like that.

Thank question was a 2 part question, because I don't know the background variable.

Actually I think I just need to modify the background to the Table to a Transparent Pink or Blue. Dang if I know how to do that...

Shamun 07-15-2010 01:05 PM

Re: Changing the background color based on Category
 
The variable for the category number.
I have no idea right now if its $cat.id or $cat.num or $cat or whatever. There is no variable for background color.

minfinger 07-15-2010 07:21 PM

Re: Changing the background color based on Category
 
Back ground color goes in the ul.bestsellers-products-item

ul.bestsellers-products-item-m li {
margin: 10px 0px 10px 0px;
list-style: none;
background-color:#b0c4de;
border-color:#f06300;
border-style:solid;
border-width:3px 2px;
padding: 0px;

I'm not positive about the $cat stuff either, I'll keep looking.

ARW VISIONS 07-16-2010 12:33 AM

Re: Changing the background color based on Category
 
Ok so in your .tpl you will find class="bestsellers-products-item-m"

this controls the background color.

you need to code the tpl to change this class based on category.

so in your .tpl you would have

{if $cat eq '8'}
class="bestsellers-products-item-m-blue"
{elseif $cat eq '10'}
class="bestsellers-products-item-m-pink"
{else}
class="bestsellers-products-item-m"
{/if}

then create appropriate class in your CSS

minfinger 07-16-2010 04:33 AM

Re: Changing the background color based on Category
 
ARW,

Yup, already did that. Except the "-m" represents male in my css and "-f" female.

The code in the bestsellers.tpl that sets that class is:

Code:

{if $bestsellers}
  {capture name=bestsellers}
    <ul class="bestsellers-products-item-m">
      {foreach from=$bestsellers item=bestseller}
        <li>


Do I build the {if} formula inside the "<ul>" ?

I tried the following and that did work to well.
{if $cat eq '8'}
<ul class="bestsellers-products-item-m">
{elseif $cat eq '10'}
<ul class="bestsellers-products-item-f">
{else}
<ul class="bestsellers-products-item">
{/if}

It messed it up like it didn't have a Class at all.

Shamun 07-16-2010 08:18 AM

Re: Changing the background color based on Category
 
Code:

{if $bestsellers}
  {capture name=bestsellers}
    {if $cat eq '8'}
        <ul class="bestsellers-products-item-m">
    {elseif $cat eq '10'}
        <ul class="bestsellers-products-item-f">
    {else}
        <ul class="bestsellers-products-item">
    {/if}
      {foreach from=$bestsellers item=bestseller}
        <li>


try that.

ARW VISIONS 07-16-2010 09:20 AM

Re: Changing the background color based on Category
 
tals version should work fine

minfinger 07-16-2010 06:12 PM

Re: Changing the background color based on Category
 
Alright I will this weekend. If I can't nail this, I think I'll get paid :D


All times are GMT -8. The time now is 05:18 PM.

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