Forum for discussing general topics related to Couch.
15 posts Page 1 of 2
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.
Hi,

I'm using the following <cms:pages> method and logic - shown by KK - to display next/previous post on my Portfolio page:

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>


So my code is:

Code: Select all
<cms:pages stop_before=k_page_date limit='1'>
                 <div class="col-lg-6 col-sm-6">
                    <a href="<cms:show k_page_link />" class="portfolio-box">
                        <img src="<cms:show thumb />" class="img-responsive" alt="">
                        <div class="portfolio-box-caption">
                            <div class="portfolio-box-caption-content">
                               <h5><cms:date k_page_date format='d.m.Y' /></h5>
                               <h4><cms:show en_titulo /></h4>
                            </div>
                        </div>
                    </a>
                </div>
</cms:pages>     

  <cms:pages start_on=k_page_date order='asc' limit='1' offset='1'>
                 <div class="col-lg-6 col-sm-6">
                    <a href="<cms:show k_page_link />" class="portfolio-box">
                        <img src="<cms:show thumb />" class="img-responsive" alt="">
                        <div class="portfolio-box-caption">
                            <div class="portfolio-box-caption-content">
                               <h5><cms:date k_page_date format='d.m.Y' /></h5>
                               <h4><cms:show en_titulo /></h4>
                            </div>
                        </div>
                    </a>
                </div>
</cms:pages>     


Works like a charm.
My question is: is there any simple way to loop all posts and:

— display the first post when you hit the last post
— display the last post when you hit the first post

This way I won't have any empty spaces when user is seeing 1st and last post.
Thank you so much!
— display the first post when you hit the last post
— display the last post when you hit the first post

Empty space occurs when cms:pages doesn't return any results. Such cases can be handled by <cms:no_results> tag-pair placed inside cms:pages. Place appropriate code that fetches last-fist posts inside the no_results..
15 posts Page 1 of 2
cron