Jump to content
cb2004

Enable pagination to just be prev/next

Recommended Posts

Pagination in Processwire is so simple, however it would be so much better if you could set numPageLinks to 0 and this would just leave previous and next links. At the moment I have to code this myself.

Share this post


Link to post
Share on other sites

The simple solution is:

.MarkupPagerNav li {
    display: none;
}
.MarkupPagerNavPrevious, .MarkupPagerNavNext {
    display: inline;
}

---

EDIT: actually, did you try to set the "numPageLinks" options to 0?

$results->renderPager(array(
    'numPageLinks' => 0
));  

I don't know if it works, but it's worth trying

  • Like 1

Share this post


Link to post
Share on other sites

Hi Diogo.

Yes I did try that. No joy, seemed to set the default. The CSS solution is good enough for now. Thanks.

  • Like 1

Share this post


Link to post
Share on other sites

Hi @cb2004, I solved this with this code:

$news = $page->children("limit=5");
$pager = $modules->get('MarkupPagerNav');
// this is required in order for getUrl to work
// see https://processwire.com/api/ref/markup-pager-nav/get-u-r-l/
$pager->render($news);

$paginationMarkup = '';

if ($news->hasPrevPagination() || $news->hasNextPagination()) {
  $paginationMarkup .= '<ul>';

  if ($news->hasPrevPagination()) {
    $paginationMarkup .= "<li><a href='{$pager->getUrl($pager->pageNum - 1)}'>prev</a></li>";
  }

  if ($news->hasNextPagination()) {
    $paginationMarkup .= "<li><a href='{$pager->getUrl($pager->pageNum + 1)}'>next</a></li>";
  }

  $paginationMarkup .= '</ul>';
}

echo $paginationMarkup;

 

Share this post


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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...