per category styles

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
Maex
Regular
Posts: 11
Joined: Sun Jun 24, 2007 9:41 pm
Location: München, Germany
Contact:

per category styles

Post by Maex »

Hi!

I am trying to set a different headline background image depending on the category the blog is displaying the content for. This should also work for articles not only "browse category".

A few questions ;-)

The "style.css" of the template is static and not processed by the smarty engine, correct?

$category is only set if the blog is browsed "by category" and $entry_id is only set if the blog is browsed by single articles (for index.tpl).

Is there a possibility to get the $category number if one does know the $entry_id (single article) in *.tpl files?

Would it be a "correct" approach to modify the inclusion of the serendipity.css in index.tpl like <cat>_serpendipity.css and then handle this in a modified serendipity.css.php or is there a less rude way?

Simply pointing me to examples or documentation is perfectly ok ;-)

Thanks,
\Maex
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

I have no idea what template you are using, however, a really simple way to accomplish your objective would be to use the "properties/templates of categories" plugin. Using that plugin, each category can have a different template - which can be substantially identical, or vastly different, from each other.

If you have 5 categories, wish to use substantially the same stylesheet for each, you could copy that template to 5 different folders in your /templates/ directory. If the template has an info.txt file, you might wish to change the template name for each of them within that file to make them easier to recognize when assigning the template to a particular category.

A nice thing about the plugin is that you can define a precedence for the templates in the event an entry is assigned to more than a single category.
=Don=
Maex
Regular
Posts: 11
Joined: Sun Jun 24, 2007 9:41 pm
Location: München, Germany
Contact:

Post by Maex »

Thanks a bunch.

With this plugin one can still have only one style.css but with per category templates this is a restriction I can live with ;-)

Thanks again and also for the quick response!
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

Be sure to show us your finished project!
=Don=
Post Reply