Keyword

Odd/even classes on items listed in category view

  • Mister Andreas
  • Mister Andreas's Avatar Topic Author
  • Offline
  • New Member
More
14 years 3 months ago #85016 by Mister Andreas
Hi everyone!
I wan't to show every second item in category view listings with a different background color. For example:

First item in the list is white then the secound would be gray, and the third is white again and so on....

Thanks in advance!

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

More
14 years 3 months ago #85017 by william white
Replied by william white on topic Odd/even classes on items listed in category view
Can you call the
/* --- Zebra rows --- */
.even {background:#fffff0;padding:2px;border-bottom:1px dotted #ccc;}
.odd {background:#fff;padding:2px;border-bottom:1px dotted #ccc;}

in your category.php in a similar way that they are used in the item.php

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

  • Mister Andreas
  • Mister Andreas's Avatar Topic Author
  • Offline
  • New Member
More
14 years 3 months ago #85018 by Mister Andreas
Replied by Mister Andreas on topic Odd/even classes on items listed in category view
Yes that is possible but I have to have som phpcode to determine either the catitem view id(or item id...something) is odd or even and then setting the class to odd/even.

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

More
13 years 7 months ago #85019 by Emmanouil
Hello Mister Andreas,

did you manage to solve this? Is there any upadate?

Thanks in advance.

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

More
12 years 1 month ago - 12 years 1 month ago #85020 by Jan Surovy
Hi guys,
I managed to solve it, thanks to William's clue. Thank you.

Open up the file root/components/com_k2/templates/default/category.php
- replace default if you use separate k2 template

Find
<div class="itemContainer
- choose if you want to affect leading or primary items

Paste following code just behind "itemContainer
<?php echo ($key%2) ? "odd" : "even"; ?>
- leave blank space on each side of this code if there's another class in the neighborhood

In my case, it does the job.

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


Powered by Kunena Forum