Jump to content

Enable pagination to just be prev/next


cb2004
 Share

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.

Link to comment
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
Link to comment
Share on other sites

  • 4 years later...

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;

 

  • Thanks 1
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...