Jump to content

Recommended Posts

Posted

What's the best way to return 5 next and 5 previous pages?

If there're no 5 pages return what's remaining

Should I use nextUntil() and prevUntil()?

Posted

I don't know of a built in way but I'm happy to learn ?

Not sure if that's the best way to do it but it works:

$i = 0;
$prev = new PageArray();
$next = new PageArray();
$p = $n = $page;
while($i++ < 5) {
    if($p and $p = $p->prev and $p->id) $prev->add($p);
    if($n and $n = $n->next and $n->id) $next->add($n);
}
db($prev, "prev");
db($next, "next");

0gV6Wic.png

  • Thanks 1

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...