Jump to content

how to have a different stylesheet per category


Recommended Posts

Hi,

if anyone could help that would be great.

 

I want to style categories differently. How can i include a different style sheet depneding on the main category the product is in?

 

So category_id = 6 show style sheet cat6.css for example.

 

And all products in category 6 would use the same style sheet.

 

And so on for other category ids, eg cat id 7 links to cat7.css etc etc.

 

Thanks.

Edited by nineten (see edit history)
Link to comment
Share on other sites

  • 6 months later...

Yes, you could use the same syntax in PS 1.5.x

 

However, a cleaner solution would be to add a new class with the category id in the name.

 

IE

<div class="category_{$category->id_category}">

 

Then you can add specific styling in 1 CSS file, and have it reference the specific category

IE

.category_34 { some code }
.category_20 {some other code}

  • Like 1
Link to comment
Share on other sites

Tomerg3

Thanks for the reply - It's nice to see experienced people trying to help the rest of us out.

I wish I understood better php better and how to implement the first part of what you said.... the css part I got.

 

Hopefully someone will get some good use out of your suggestion. It really is useful.

Edited by Whispar1 (see edit history)
Link to comment
Share on other sites

Hello Shacker,

Would this also apply to 1.5.3.1?

I am assuming you are editing the category.tpl file?

 

I too would like some slight modification to one section of my category pages.

Thank You for any clarification you can offer.

works on thius version, and is in the header.tpl file in the head section

  • Like 1
Link to comment
Share on other sites

Thank you guys for the clarification - its a big help.

The section that I want to change and make unique for each category is the three boxes seen here:

http://69.36.191.225/index.php?id_category=16&controller=category

 

The three boxes at the top of the category that say (shop / style / sale) are what I want to be different for each category.

Changing the content of these three boxes is handled in the BO through the module supplied by the developer.

 

Looking at it, maybe it's more complicated than simply adding smarty code and then creating classes for each category because

the content is changes through the module. Maybe I just need to put something generic in them or just comment out the block all together if what I want to do is too complicated.

Link to comment
Share on other sites

If someone wouldn't mind helping me understand this, here is the section of code in category.tpl that calls the three boxes I want

to be unique for each category.

 

 

<!-- cart baner -->

<div class="category-description std">

<div class="row">

{$sccop.trendy_category_page_markup|html_entity_decode}

</div>

</div>

<!-- end the cart baner -->

 

Is this the best place to add the smarty code then add the specific css as stated above to say category.css?

Link to comment
Share on other sites

See http://screencast.com/t/yoyF2wGX

 

While I don't see a simple way to add a class the each of the 3, you can add a class to their container.

 

[color=#343943][font=Arial, Helvetica, sans-serif][size=3]<div class="category-description std category_{$category->id_category}">[/size][/font][/color]

 

This will add a new class categoy_xx where xx is the category id

Link to comment
Share on other sites

×
×
  • Create New...