Jump to content
rjgamer

[SOLVED] Pagination rendered but does not work

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

Share this post


Link to post
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.

Share this post


Link to post
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

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...