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)
-   -   Load different style sheets for main categories (https://forum.x-cart.com/showthread.php?t=63616)

tech@vrve.co 05-14-2012 07:02 AM

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

totaltec 05-14-2012 07:12 AM

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.

tech@vrve.co 05-14-2012 07:29 AM

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

cflsystems 05-14-2012 07:53 AM

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

tech@vrve.co 05-14-2012 08:11 AM

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

cflsystems 05-14-2012 08:14 AM

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.

tech@vrve.co 05-14-2012 08:30 AM

Re: Load different style sheets for main categories
 
Sorry still don't understand.
Is this something you could do for me?
Thanks

cflsystems 05-14-2012 08:44 AM

Re: Load different style sheets for main categories
 
Yes I can code this for you. Email me with details what exactly is needed

kdw 05-15-2012 07:23 AM

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

totaltec 05-15-2012 07:31 AM

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} 



All times are GMT -8. The time now is 06:48 AM.

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