Jump to content

[SOLVED] Pagination rendered but does not work


Alpine418
 Share

Recommended Posts

Hi folks,

my current pagination implementation does not work. The research via Google and this forum did not result in a success.

Some details:

  • The template of the pages has pagination enabled in the admin.
  • URL Segments are not enabled.
  • The buttons are correctly rendered.
  • Clicking on  the "Next" or numbered links merely reloads the current page.
  • The link href values are properly being output with the current page url with ?page=1, ?page=2, etc.
  • Manually entering the paginated urls has the same effect of reloading the current page with no new content.
  • Pages are being returned from the ->find function properly and with the proper limit.

A few other details:

  • ProcessWire v3.0.140
  • Multi-language is enabled, 2 languages implemented, only one is use.

Implemented as partial of a partial of a "Repeater Matrix"-field.

...
echo $items->renderPager([
        'listMarkup' => '<nav aria-label="navigation"><ul class="pagination">{out}</ul></nav>',
        'itemMarkup' => '<li class="page-item {class}">{out}</li>',
        'linkMarkup' => '<a class="page-link" href="{url}">{out}</a>',
        'currentLinkMarkup' => '<a class="page-link" href="{url}">{out}</a>',
        'currentItemClass' => "active"
]);
...
File: partials/feed/items/list.php
<div id="feedItems">
    <div class="container">

        <?= wireRenderFile('partials/feed/items/list', [
            'items' => $items,
        ]); ?>

    </div>
</div>

File: File: partials/feed/items.php
echo wireRenderFile('partials/content-section', [
    'title' => $page->section_title,
    'body' => wireRenderFile('partials/feed/items', [
        'items' => $pages->find('limit=2, template=feed-item, feed_item_published<=' . time() . ', sort=-feed_item_published'),
    ])
]);
          
File: fields/section/section_feed.php

Thanks for help...

Edited by rjgamer
Problem solved
Link to comment
Share on other sites

2 hours ago, rjgamer said:
  • The link href values are properly being output with the current page url with ?page=1, ?page=2, etc.
  •  

Perhaps not much help, but I find it strange that it adds query strings. The page numbers should actually be rendered like this:

http://demo.processwire.com/cities/new-york-city/page2

Do you find any hints in any of these places?

  • browser JS console
  • Tracy Debugger
  • PW error logs

Perhaps also check the browser network panel, to see if the page(s) return HTTP 200 or a redirect.

Link to comment
Share on other sites

Found the problem: The autodetection does not detect the current page. Instead it detects and uses the Repeater Matrix page as current page, which does not have a template with allowPageNum enabled.

Fix: Add the real page as option to the pager if you need pagination in Repeater Matrix. Check 3rd line:

...
echo $items->renderPager([
        'page' => wire('page'),
        'listMarkup' => '<nav aria-label="navigation"><ul class="pagination">{out}</ul></nav>',
        'itemMarkup' => '<li class="page-item {class}">{out}</li>',
        'linkMarkup' => '<a class="page-link" href="{url}">{out}</a>',
        'currentLinkMarkup' => '<a class="page-link" href="{url}">{out}</a>',
        'currentItemClass' => "active"
]);
...
File: partials/feed/items/list.php

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...