Page 1 of 1

per category styles

Posted: Wed Sep 24, 2008 6:53 pm
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

Posted: Wed Sep 24, 2008 7:20 pm
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.

Posted: Wed Sep 24, 2008 8:16 pm
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!

Posted: Wed Sep 24, 2008 9:40 pm
by Don Chambers
Be sure to show us your finished project!