Skip to content

Instantly share code, notes, and snippets.

@ucay
Created January 20, 2016 14:06
Show Gist options
  • Save ucay/d5ecd9aca05c1ca47c3a to your computer and use it in GitHub Desktop.
Save ucay/d5ecd9aca05c1ca47c3a to your computer and use it in GitHub Desktop.
CouchCMS Pages - Grouping every x post
<!-- Grouping every 4 posts -->
<cms:set fields='4' />
<!-- check index if the first in a row [ (index-1) modulus 4 == 0 ] -->
<cms:set temp="<cms:sub k_count '1' />" />
<cms:set first_in_row="<cms:mod temp fields />" />
<cms:if first_in_row == '0' >
<div class="row">
</cms:if>
<!-- show content -->
<div class="col-md-3">contents goes here</div>
<!-- check index if the latest in a row, or the latest page -->
<cms:set last_in_row="<cms:mod k_count fields />" />
<cms:if last_in_row == '0' || k_count == k_total_records_on_page >
</div>
</cms:if>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment