Post by 900pixels » Tue Aug 31, 2010 7:03 pm

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!

Active Member

Posts

Joined
Tue Dec 08, 2009 1:36 pm

Post by 900pixels » Tue Aug 31, 2010 9:57 pm

An update-
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?

Active Member

Posts

Joined
Tue Dec 08, 2009 1:36 pm

Post by Qphoria » Tue Aug 31, 2010 10:40 pm

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') { ?>

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by 900pixels » Wed Sep 01, 2010 5:55 am

Thankyou so much Q.
You are a legend!

Active Member

Posts

Joined
Tue Dec 08, 2009 1:36 pm

Post by webpie it. » Sun Feb 13, 2011 5:50 pm

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

Regards

Chris


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by 900pixels » Wed Feb 16, 2011 6:45 am

Just look in the header.tpl file for the stylesheet.css link and put it after that.

Active Member

Posts

Joined
Tue Dec 08, 2009 1:36 pm

Post by taylordsmith » Fri Feb 17, 2012 7:58 am

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

OpenCart V1.5.1.3.1


Newbie

Posts

Joined
Tue Jan 31, 2012 9:47 am

Post by Opencart_k » Fri Jun 09, 2017 9:08 pm

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.

Newbie

Posts

Joined
Thu May 25, 2017 9:27 pm
Who is online

Users browsing this forum: No registered users and 42 guests