Jump to content

Recommended Posts

Posted

I have a selector which is pretty simple and just fetches a series of pages except for the current page.

1,2,3,4,5,6,7

When you're on page 1, the output is
2,3,4,5,6,7

When you're on page 2, the output is
1,3,4,5,6,7

$services=$pages->find("template=a-practice-area, id!=$page, sort=sort "); 
foreach($services as $service) {
echo "
<div>...

 

Currently, the array (is that what it's called? starts from the first item (service) in the tree and continues.

I'd now like to start the array from the next item in the array instead always starting at the first.

IE if you were on page 2, the output is
3,4,5,6

IE if you were on page 4, the output is
5,6,7

Looking at the docs, a selector called 'start' is mentioned.

Quote

That selector tells ProcessWire to return 50 (or fewer) results. The starting result is always the first, unless you use the "start" reserved word, i.e.


start=50, limit=50
2

I think this is what I need and have tried the following to no avail

<?php $services=$pages->find("template=a-practice-area, id!=$page, sort=sort, start=$page"); 

Any tips?

 

 

 

Posted

Citing from the linked doc pages:

Quote

Returns all matching pages after this one, or integer if $count option specified.

Here "$count option" should read "getQty" option, shouldn't it?

Posted
1 hour ago, LostKobrakai said:

Why would there if you need a "current" page to be able to do all of that?

You're right - thank you.

So I adapted my code to use page instead of pages and this modfied version works

 $items = $page->nextAll('template=a-practice-area');
foreach($items as $item) {
echo "

IE if you were on page 4, the output is
5,6,7

Is there a method to restart  the array after it reaches the end so that the output is

5,6,7,1,2,3,4

 

Posted
53 minutes ago, LostKobrakai said:

Reverse the second part?

After trying various sort and reverse options, I saw you post, tried again and it's perfect now ?

$does2 = $page->prevAll("template=a-practice-area")->reverse();
foreach($does2 as $do2)

 

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