Forum

Thread tagged as: Question, Problem, Blog

Pagination stopped working

The pagination on the my blog posts has stopped working. If you click on 'next' (1 of 4) it just stays on the same page (page1).

   <perch:if exists="paging">
    <div class="paging">
        Page
        <perch:blog id="current_page" /> of
        <perch:blog id="number_of_pages" />
        <perch:blog id="page_links" encode="false" />
        <perch:if exists="not_first_page">
            <a href="<perch:blog id=" prev_url " encode="false " rewrite="/blog/{cat:category:%s/}{page:page/%s} "/>"  
    rel="prev">Previous</a>
        </perch:if>
        <perch:if exists="not_last_page">
            <a href="<perch:blog id=" next_url " encode="false " rewrite="/blog/{cat:category:%s/}{page:page/%s} "/>" rel="next">Next</a>
             </perch:if>
          </div>
       </perch:if>
      </perch:after>
David Roberts

David Roberts 0 points

  • 5 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

Please post your Diagnostics Report with each post to the forum.

Also, what happened before it stopped working? The code can't break itself so something has changed.

Also, what happened before it stopped working? The code can't break itself so something has changed.

The only things that have happened is that I have styled the pagination with CSS and updated perch.

Diagnostics Report below. Perch Runway: 2.8.29, PHP: 5.5.31, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 15d5c781cfcad91193dceae1d2cdd127674ddb3e $, with PDO Server OS: Linux, cgi-fcgi Installed apps: content (2.8.29), assets (2.8.29), categories (2.8.29), perch_blog (4.6), perch_kraken (1.0), collection_1 (2.8.29), perch_backup (1.2), perch_mailchimp (3.0.1) App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_mailchimp', ); PERCH_LOGINPATH: /perch PERCH_PATH: /home4/digitale/public_html/perch PERCH_CORE: /home4/digitale/public_html/perch/core PERCH_RESFILEPATH: /home4/digitale/public_html/perch/resources Image manipulation: GD Imagick PHP limits: Max upload 128M, Max POST 128M, Memory: 128M, Total max file upload: 128M F1: 2edba60ed1f613d6dd804feb202456a2 Resource folder writeable: Yes SCRIPT_NAME: /perch/core/settings/diagnostics/index.php REQUEST_URI: /perch/core/settings/diagnostics/ DOCUMENT_ROOT: /home4/digitale/public_html HTTP_HOST: digitaleducation.education

Drew McLellan

Drew McLellan 2638 points
Perch Support

It looks like you've updated Perch but you've not updated Blog to go along with it. The current version is 5.0.

Updated to v5.00 still have the same issue.

Drew McLellan

Drew McLellan 2638 points
Perch Support

What code are you using to display the listing that has no pagination?

Top of this page is what I am using for pagination. It does not move from 1 to 2 2 to 3 etc just stays on the same page when you click next.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show me your function call in the page? Something like perch_blog_custom(...)

 <?php perch_layout('header.blog'); ?>
  <?php perch_layout('header.main'); ?>

     <div class="content-holder">

        <?php 
            perch_blog_custom(array(
            'template' => 'blog/post_in_list.html',
            'sort' => 'postDateTime',
            'sort-order' => 'DESC',
            'section' => 'Blog',
    ));
        ?>

        </div>


        <?php perch_layout('sidebar.blog'); ?>


            <?php perch_mailchimp_form('subscribe.html'); ?>

              <?php perch_layout('global/global.footer'); ?>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you try adding the option:

'paginate' => true,

so it reads:

perch_blog_custom(array(
            'template' => 'blog/post_in_list.html',
            'sort' => 'postDateTime',
            'sort-order' => 'DESC',
            'section' => 'Blog',
            'paginate' => true,
    ));

Added, no change.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show me what the debug outputs now?

Debug output:

  Debug Message
  [18] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM perch2_pages p LEFT JOIN   perch2_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC, p.pagePath ASC
  Matched page: /blog, so not using routes.
Using master page: /templates/pages/blog/index.php
[1] SELECT * FROM perch2_pages WHERE pagePath='/blog' LIMIT 1
Using template: /templates/pages/attributes/default.html
Using sub-template: /templates/pages/attributes/seo.html
Using sub-template: /templates/pages/attributes/twitter.html
Using sub-template: /templates/pages/attributes/facebook.html
[4] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageDepth >=0 AND pageDepth<=1 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/blog' LIMIT 1
[1] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-002', '000') ORDER BY pageTreePosition DESC
[4] Using template: /templates/navigation/item.html
[1] SELECT * FROM perch2_blog_sections WHERE sectionSlug='Blog' LIMIT 1
[10] SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM perch2_blog_index idx JOIN perch2_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN perch2_blog_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='postID' AND idx2.indexKey='postDateTime' WHERE 1=1 AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY idx.itemID, idx2.indexValue, postID ) as tbl WHERE ( sectionID='3' AND postStatus='Published' AND postDateTime<='2016-06-02 12:23:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 0, 10
[1] SELECT FOUND_ROWS() AS `count`
[42] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
[10] Using template: /templates/blog/post_in_list.html
[3] SELECT * FROM perch2_blog_sections ORDER BY sectionTitle ASC
[1] SELECT * FROM perch2_blogs ORDER BY blogTitle ASC
Using template: /templates/search/search-form.html
Using template: /templates/mailchimp/subscribe.html
[1] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/blog' OR regionPage='*' ORDER BY regionPage DESC
Request time: 0.3002
Process time: 0.2997
  Memory: 4.3518
Drew McLellan

Drew McLellan 2638 points
Perch Support

That looks like it's filtering for the first 10 correctly. Does the output change for page 2?

What's the URL for page 2?

I am only on 1-4 pages

This is page 2

  Debug Message
  [18] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM perch2_pages p LEFT JOIN   perch2_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC, p.pagePath ASC
Matched route: blog/page/[i:page]
Using master page: /templates/pages/blog/index.php
Page arguments:
Array
(
    [0] => /blog/page/2
    [page] => 2
    [1] => 2
)
[1] SELECT * FROM perch2_pages WHERE pagePath='/blog' LIMIT 1
Using template: /templates/pages/attributes/default.html
Using sub-template: /templates/pages/attributes/seo.html
Using sub-template: /templates/pages/attributes/twitter.html
Using sub-template: /templates/pages/attributes/facebook.html
[4] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageDepth >=0 AND pageDepth<=1 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/blog' LIMIT 1
[1] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-002', '000') ORDER BY pageTreePosition DESC
[4] Using template: /templates/navigation/item.html
[1] SELECT * FROM perch2_blog_sections WHERE sectionSlug='Blog' LIMIT 1
[10] SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM perch2_blog_index idx JOIN perch2_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN perch2_blog_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='postID' AND idx2.indexKey='postDateTime' WHERE 1=1 AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY  idx.itemID, idx2.indexValue, postID ) as tbl WHERE ( sectionID='3' AND postStatus='Published' AND  postDateTime<='2016-06-02 13:55:00' ) GROUP BY itemID, sortval ORDER BY sortval DESC LIMIT 10, 10
 [1] SELECT FOUND_ROWS() AS `count`
 [42] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
 [10] Using template: /templates/blog/post_in_list.html
 [3] SELECT * FROM perch2_blog_sections ORDER BY sectionTitle ASC
 [1] SELECT * FROM perch2_blogs ORDER BY blogTitle ASC
 Using template: /templates/search/search-form.html
 Using template: /templates/mailchimp/subscribe.html
 [1] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/blog' OR regionPage='*'   ORDER BY regionPage DESC
 Request time: 0.0779
 Process time: 0.0775
  Memory: 4.3551
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, that looks correct - it's getting 10 records from record 10 onwards.

So, is there a reason it is not working on the site?

Drew McLellan

Drew McLellan 2638 points
Perch Support

It looks like it is working to me. Is the page online?

It is https://digitaleducation.education/blog but the server is down!! its just being rebooted, so I would wait half an hour or so or I will repost when it is up.

It is back up now.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Well that's very strange, I have tried it on:

Google, Google developer edition, Firefox, Firefox developer edition, Safari, iPad, iPhone and I get the same results each time, it just stays on page 1?

If you look at the source code, should there not be a link for <a href="" instead of blank?

<div class="paging"> Page 1 of 4 <a href="" rel="next">Next</a> </div>