Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Load different style sheets for main categories

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 05-14-2012, 07:02 AM
 
tech@vrve.co tech@vrve.co is offline
 

Newbie
  
Join Date: May 2012
Posts: 5
 

Default Load different style sheets for main categories

I need to change the style sheet and store logo based on different main categories.
I am using the latest Version 4.5.0
I need the new style sheet to persist in all sub categories and products.
I know it can probably be done with an if...else block but need help.
Thanks
__________________
Version 4.5.2
Reply With Quote
  #2  
Old 05-14-2012, 07:12 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Load different style sheets for main categories

Not an easy request unfortunately. I am thinking about how this might be accomplished...

It is easy to write an if statement for the category page itself in smarty:
PHP Code:
{if $cat eq 1}
 Do 
this
{elseif $cat eq 2}
 Do 
that
{/if} 

Getting it to stick on all the sub cats and products is going to be the tough part. You will have to write some php code that looks at the entire category structure, then determines which main category this particular product or category is in. Certainly not impossible, but a little daunting.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #3  
Old 05-14-2012, 07:29 AM
 
tech@vrve.co tech@vrve.co is offline
 

Newbie
  
Join Date: May 2012
Posts: 5
 

Default Re: Load different style sheets for main categories

What if i had a comma separated list of cat IDs.
If $catid IN '22,23,25,35" .........

Where would I put this if statement, in which file?
many thanks
__________________
Version 4.5.2
Reply With Quote
  #4  
Old 05-14-2012, 07:53 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Load different style sheets for main categories

I have done this for a client. You need to get your main cats assigned to smarty at all times with the one being used assigned as well so you can base the css file load on it. Then in templates you just use an if statement which css file to load. It has to be done in php
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #5  
Old 05-14-2012, 08:11 AM
 
tech@vrve.co tech@vrve.co is offline
 

Newbie
  
Join Date: May 2012
Posts: 5
 

Default Re: Load different style sheets for main categories

Thanks. I don't fully understand what you mean by 'cats assigned to smarty at all times'.
Appreciate your help here.
Thanks
__________________
Version 4.5.2
Reply With Quote
  #6  
Old 05-14-2012, 08:14 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Load different style sheets for main categories

Your php code have to pick the main categories you want to use and assign them to smarty on each and every page, as well as specifically point out which one is to be used.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #7  
Old 05-14-2012, 08:30 AM
 
tech@vrve.co tech@vrve.co is offline
 

Newbie
  
Join Date: May 2012
Posts: 5
 

Default Re: Load different style sheets for main categories

Sorry still don't understand.
Is this something you could do for me?
Thanks
__________________
Version 4.5.2
Reply With Quote
  #8  
Old 05-14-2012, 08:44 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Load different style sheets for main categories

Yes I can code this for you. Email me with details what exactly is needed
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #9  
Old 05-15-2012, 07:23 AM
 
kdw kdw is offline
 

Member
  
Join Date: Oct 2011
Posts: 17
 

Default Re: Load different style sheets for main categories

Had an idea!
With clean URLs set the URL can/will contain the category name?
What smarty or PHP code would look for a word inside the URL and load image/css based on what it finds eg. {if strpos($smarty.get.page, "SWCHS.html") !== false}
<p>SWCHS image/CSS</p>
{else}
default image/css
{/if}

Would something like that work?
If so what code should I use as my example is not finding SWCHS
Keith
__________________
tech990
Reply With Quote
  #10  
Old 05-15-2012, 07:31 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Load different style sheets for main categories

Have you tested by simply putting {$smarty.get.page} and seeing what the results are? I believe that variable shows the result of _get requests.

Try {$smarty.server.REQUEST_URI}:
PHP Code:
{if strpos($smarty.server.REQUEST_URI"SWCHS.html") !== false}
  <
p>SWCHS image/CSS</p>
{else}
  default 
image/css
{/if} 
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote

The following user thanks totaltec for this useful post:
kdw (05-15-2012)
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:16 PM.

   

 
X-Cart forums © 2001-2020