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.
http://forum.opencart.com/viewtopic.php ... 351#p60483
Thanks for any help you guys can offer!
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 } ?>
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 } ?>
Would SEO URLs be better?
Code: Select all
<?php if (!isset($this->request->get['route']) || $this->request->get['route'] == 'product/category&path=18) { ?>
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') { ?>
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
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
Can the same be applied in opencart Version 2.3.0.2 ? Because I want to have different stylesheet in categories and this would not work for it.
Who is online
Users browsing this forum: No registered users and 42 guests