Jump to content

Pageination without paging


h4r4ld
 Share

Recommended Posts

HI hi :)

I'm currently working on pageination my documentlisting. I Have enabled the MarkupPagerNav module and activated allow page numbers on the documentholder template. 

I'm using some different selectors, but as for the tests I would go with this one :

$documentHolder = $pages->find("template=documentHolder, status=hidden, limit=2, sort=created, docownerid={$user->id}");

the documentholder has 4 pages, so while using limit=2 there are 2 pages, which is working as expected. Next I try to give the 1,2, next appearing.

Using this: 

echo $pagination = $documentHolder->renderPage();

I get an array to string conversion message and no pageitems. 

Using this:

echo $documentHolder->render()

Theres no error and the pageitems are showing up, but if I try to page to page 2 PW tries to open /?page=2 and fetches the same items as on default/page1.

Where is my mistake?

Thanks 

Harri

Link to comment
Share on other sites

renderPager() should be correct -> https://processwire.com/api/modules/markup-pager-nav/

Thanks for that hint, got it working now.

How about using 2 paginations for different tables on one page?

For example, I have a landingpage showing the newest documents, newest users, ... now I would like to add pagination to every table of this. Is this possible or do I allways page every overview to page2 if I click on any of those /page2 links?

Link to comment
Share on other sites

Your code did miss the r, that's why I asked. Multiple paginations are doable, but you need to make use of the getVars setting and manage the start position of both find calls on your own.

function pageStart($limit){
    $limit = (int) $limit;
    if($input->pageNum === 1 || $limit < 1){
      return 0;
    }

    return ($input->pageNum - 1) * $limit;
}
$limit = 15;
$first = $pages->find("…, limit=$limit, start=" . ($input->get->first ? pageStart($limit) : 0);
// Will be merged to form getVars
// If you don't otherwise use the feature to ship e.g. filter settings to paginated pages
// you could also directly manipulate the getVars via the pager settings.
$input->whitelist("first", 1); 

// generate pagination 1

$limit = 12;
$second = $pages->find("…, limit=$limit, start=" . ($input->get->second ? pageStart($limit) : 0);
$input->whitelist("second", 1);
$input->whitelist("first", 0);

// generate pagination 2

  • Like 4
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...