Forum for discussing general topics related to Couch.
8 posts Page 1 of 1
There is a way to add next / prev pages link? When it is cloned the pages.

As I see i can only display pagination on the list/archive/folder page?!
Hi,

Actually showing the next and prev pages for the current page is much more complex than it appears at first sight.
For example suppose you are using the 'pages' tag to list all pages that have the term 'London' in a particular editable region. Suppose this listing brings up 12 pages. Clicking on any one page will show up that page in page-view. Now if we were to show the prev and next buttons, these buttons should lead only to the adjacent pages in the set of 12.
Suppose again that in another listing we use the 'pages' tag to list all pages of a particular date and this time only 4 pages come up. As it would happen, the same page that we clicked above also belongs to this set of 4. Now if were to open it in page-view, the next and prev buttons should show only the adjacent pages in the set of 4.
Clearly the page somehow has to aware of the context of the list it has been called from and hence the complexity.

However, if you wish to show next prev pages based on a fixed parameter e.g. publish_date, as in a blog, you can do so by using the regular 'pages' tag in the page_view as follows -
Code: Select all
<ul>
        <cms:pages start_on=k_page_date order='asc' limit='1' offset='1'>
            <li><a href="<cms:show k_page_link />">Newer</a></li>
        </cms:pages>

        <cms:pages stop_before=k_page_date limit='1'>
            <li><a href="<cms:show k_page_link />">Older</a></li>
        </cms:pages>
</ul>

Notice how we use the current page's publish date to fetch it's next and previous neighbours.
Of course you can use all other available parameters of 'pages' tag, for example to show the next page from the same folder as the current page add the 'folder' parameter.
works like charm!

thank you
I used this snippet and it works well, except when I get to the latest post, where both buttons disappear. Is there an appropriate if statement I can build around if that will remove either button when it hits the top or bottom?
The snippet itself should take care of the condition - i.e. one of the two buttons should disappear if we are one the very first or the very last page.

Could you post in the complete code of your page please?
It should give us a clue about the cause.
Hi, I am trying to implement something similar to what has been posted in this thread. I managed to get this script working fine except I would like to change the order in which they display. I have tried a few things but can't seem to get it.

I have a text field called 'order' that I use to order the listing items. This is just a number. I would like the same order when you click next/ prev in page view.

Any help would be greatly appreciated.
Hi Mark,

I am assuming that your custom field named 'order' has a 'search_type' of 'integer' (in not please set the search_type to 'integer' as follows)
Code: Select all
<cms:editable name='order' type='text' search_type='integer'>0</cms:editable>

Further assuming that each of your page has been given a unique value in the mentioned 'order' field, the following snippet should work -
Code: Select all
   <cms:if k_is_page >
   <ul>
      <cms:pages orderby='order' order='asc' custom_field="order > <cms:show order />" limit='1'>
         <li><a href="<cms:show k_page_link />">Next</a></li>
      </cms:pages>

      <cms:pages orderby='order' order='desc' custom_field="order < <cms:show order />" limit='1'>
         <li><a href="<cms:show k_page_link />">Prev</a></li>
      </cms:pages>
   </ul>
   </cms:if>

Please let me know if this helped. Thanks.
Worked perfectly. Thanks again.
8 posts Page 1 of 1

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 2 guests