by
KK » Thu May 26, 2011 1:46 am
Hi Simon,
So, as far as I could get it, you wish to display a list of pages with the top few pages shown in a certain way, followed by the next few pages in a different way, followed by next pages in altogether different way etc. Right?
Two different ways of doing so come to my mind -
1. If all the pages are shown contiguously (no other elements of the webpage coming between them), we can use a single 'pages' statement. We'll keep a count of the pages that have been displayed and then show the current page accordingly. For example, the following code will display the first 2 pages, then the next 5 pages and then all the rest in different ways -
- Code: Select all
<cms:pages masterpage='property.php' limit='10'>
<cms:if k_count le '2' >
<h1><cms:show k_page_title /></h1>
</cms:if>
<cms:if k_count ge '3' && k_count le '7' >
<h3><cms:show k_page_title /></h3>
</cms:if>
<cms:if k_count ge '8' >
<cms:show k_page_title /><br />
</cms:if>
</cms:pages>
In the snippet above, we use the variable 'k_count' to keep track of the current page's position in the list and then display it accordingly (please see
http://www.couchcms.com/docs/concepts/pagination.html for a complete list of all the variables set by Couch within the 'pages' tag that can be used for such
counting purposes. Also see
http://www.couchcms.com/docs/tags-reference/if.html for the 'ge' -greater or equal, 'le' -lesser or equal and other operators used by the 'if' tag for comparision).
To be fair, the method above might seem a bit..geekish:)
An easier method is the following that uses separate 'pages' tag for each group of pages -
- Code: Select all
<cms:pages masterpage='property.php' limit='2'>
<h1><cms:show k_page_title /></h1>
</cms:pages>
<cms:pages masterpage='property.php' limit='5' offset='2'>
<h3><cms:show k_page_title /></h3>
</cms:pages>
<cms:pages masterpage='property.php' limit='3' offset='7'>
<cms:show k_page_title /><br />
</cms:pages>
Please notice the use of the 'offset' parameter, in all the 'pages' loop other than the first, that instructs Couch to fetch pages skipping those many pages.
This method also makes it possible to use the three groups of pages at different places on the same webpage, as they are independent of each other.
Take your pick.
Do let me know if this helped.