Jump to content

How do I get the ->next field in a repeater?


PHPSpert
 Share

Recommended Posts

You can either loop through them or grab them by index - $repeater->fieldname->eq(3) ... etc

Looping would be just using foreach as with any other array in PW.

$myrepeater = $page->course_page;

foreach($myrepeater as $course){

  echo $course->fieldname;

} 
Link to comment
Share on other sites

the value of a repeater is pageArray, so getNext() should work. What value are you using as the parameter?

Edit:

Ok, quickly tested, and everything works as expected. I will post here my test so you can analyze and make sure that you are using it the right way:

$repeaterArray = $page->repeater;

$firstElement = $repeaterArray->first();

echo $repeaterArray->getNext($firstElement); //returns successfully the second element

echo $firstElement->next(); //also returns the second element
  • Like 3
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...