Forum for discussing general topics related to Couch.
3 posts Page 1 of 1
Hello, and thank you for all the effort you are putting in this great CMS.

I'm thinking to build up a special list view where posts do not look the same. So I need special classes for each post. Lets say I want 9 different posts. After the 9th it is repeating the classes so the 10th post should look like the 1st.

I came up with a solution when there is a limit of posts given. So lets say we have a limit of 18 posts per page, I can write:
Code: Select all
<div class=" post
<cms:if "k_count=1 || k_count=10"> first_class </cms:if>
<cms:if "k_count=2 || k_count=11"> second_class </cms:if>
<cms:if "k_count=3 || k_count=12"> third_class </cms:if>     
...
<cms:if "k_count=9 || k_count=18"> ninth_class </cms:if>  ">

</div>


But I guess this method is not the best solution, and what if there is no limit of posts or the limit is changing. Any Ideas for a smarter version of my idea? I need something which is repeating between 7 and 9 posts.

Thank you very much
Hi,

This is the perfect case for using cms:zebra tag (http://www.couchcms.com/docs/tags-reference/zebra.html)

As an example, the following snippet will output 'first_class' for the 1st, 5th, 9th, 13th post and so on.
Code: Select all
<div class="post <cms:zebra 'first_class' 'second_class' 'third_class' 'fourth_class' />">
..
</div>

You can specify all the nine classes and they will automatically repeat.

Hope this helps.
that's perfect, thank you very much!
3 posts Page 1 of 1
cron