Changing stylesheet depending on category?
7 posts
• Page 1 of 1
Changing stylesheet depending on category?
Hi can someone let me know how it would be possible to change the stylesheet depending on the category chosen?
In my searches I found something which may be very similar code-wise in Q's post in this thread about loading a banner depending on the page.
viewtopic.php?f=21&t=12351#p60483
Thanks for any help you guys can offer!
In my searches I found something which may be very similar code-wise in Q's post in this thread about loading a banner depending on the page.
viewtopic.php?f=21&t=12351#p60483
Thanks for any help you guys can offer!
- 900pixels
- Posts: 111
- Joined: Tue Dec 08, 2009 5:36 am
Re: Changing stylesheet depending on category?
An update-
I can get 2 different stylesheets loading for the home page and the contact us page using the code below
but I get no stylesheet if I substitute the route for something from a category like this
Can anyone shed some light on why this is happening?
Would SEO URLs be better?
I can get 2 different stylesheets loading for the home page and the contact us page using the code below
- Code: Select all
<?php if (!isset($this->request->get['route']) || $this->request->get['route'] == 'common/home') { ?>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/<?php echo $template; ?>/stylesheet/stylesheet2.css" />
<?php } ?>
<?php if (!isset($this->request->get['route']) || $this->request->get['route'] == 'information/contact') { ?>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/<?php echo $template; ?>/stylesheet/stylesheet.css" />
<?php } ?>
but I get no stylesheet if I substitute the route for something from a category like this
- Code: Select all
<?php if (!isset($this->request->get['route']) || $this->request->get['route'] == 'product/category&path=18) { ?>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/<?php echo $template; ?>/stylesheet/stylesheet.css" />
<?php } ?>
Can anyone shed some light on why this is happening?
Would SEO URLs be better?
- 900pixels
- Posts: 111
- Joined: Tue Dec 08, 2009 5:36 am
Re: Changing stylesheet depending on category?
- Code: Select all
<?php if (!isset($this->request->get['route']) || $this->request->get['route'] == 'product/category&path=18) { ?>
The route only consists of 'product/category'
You are adding the path as part of the route.. but the path is the path
Try this
- Code: Select all
<?php if (!isset($this->request->get['path']) || $this->request->get['path'] == '18') { ?>

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18210
- Joined: Mon Jul 21, 2008 7:02 pm

Re: Changing stylesheet depending on category?
Thankyou so much Q.
You are a legend!
You are a legend!
- 900pixels
- Posts: 111
- Joined: Tue Dec 08, 2009 5:36 am
Re: Changing stylesheet depending on category?
referrring to the code that loads a different style-sheet depending on page, where abouts in header.tpl do you put this and what do you remove?
Thanks
Chris
Thanks
Chris
Regards
Chris
Chris
- webpie it.
- Posts: 377
- Joined: Mon Jan 31, 2011 11:28 am
Re: Changing stylesheet depending on category?
Just look in the header.tpl file for the stylesheet.css link and put it after that.
- 900pixels
- Posts: 111
- Joined: Tue Dec 08, 2009 5:36 am
Re: Changing stylesheet depending on category?
Thanks for the solution! However, I'm running into a few problems..
How do you apply the new stylesheet to all of the subcategories and products? I can attach it to the main category page, but that's it.
Also, it is applying the new stylesheet to my home page as well - the other categories still use the default stylesheet. I assume my problems are stemming from confusion over the path structure (ie. "18" in the example).
Thanks for everyone's help so far. Any advice would be very much appreciated!
-Taylor
How do you apply the new stylesheet to all of the subcategories and products? I can attach it to the main category page, but that's it.
Also, it is applying the new stylesheet to my home page as well - the other categories still use the default stylesheet. I assume my problems are stemming from confusion over the path structure (ie. "18" in the example).
Thanks for everyone's help so far. Any advice would be very much appreciated!
-Taylor
OpenCart V1.5.1.3.1
- taylordsmith
- Posts: 12
- Joined: Tue Jan 31, 2012 1:47 am
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: davidmarch, leros2004, pelicanmike and 20 guests













