Keyword

Latest items block: style based upon category

  • William Vissenaeken
  • William Vissenaeken's Avatar Topic Author
  • Offline
  • New Member
More
10 years 10 months ago #120653 by William Vissenaeken
Latest items block: style based upon category was created by William Vissenaeken
When displaying latest item block (k2 content module) with option 'get items from categories' set: is it possible to style every item seperately, based upon its category?
e.g. latest items shows 3 items from news-category, 1 item from lifestyle-category and 5 items from travel-category. News-items would have a yellow coloured label, lifestyle-items a red, ...

How can this be achieved?

Fyi: In the category-view creating templates is no problem, because all involved items rely on one single template.

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 10 months ago #120654 by Yiota
First of all you will have to modify the k2_content_module's template you are using (i.e. Default). If you are not already using template overrides you will have to for this modification. Read here on how overrides work getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

Then all you have to do is add an extra class at the li element according to the category each item belongs to and then add the appropriate css to your template's css file.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum