Jump to content

Recommended Posts

Posted

Repeater pages are just another type of Page so it should work fine to use the $page->if() when $page is a repeater item. Using an $page->if('repeater_field', ...) when $page is a Page that has the repeater field on it will also work since RepeaterPageArray is a type of PageArray. Though let me know if you were thinking of something different. 

Posted

Using 

foreach($page->repeater as $repeaterItem) {
	echo $repeaterItem->if('inventory<10', 'Low Stock', 'In Stock');
}

Will come up with the error that 'if' is not a RepeaterPageArray function.

  • Like 1
Posted

Sure that the error refers to RepeaterPageArray in that particular line? Should be RepeaterPage instead. And if it refers to RepeaterPage, are you sure running 3.0.126?

Just tried on 3.0.126 and it works as expected.

  • Like 2
Posted

@Tom. - it seems to work fine for me also.

The one thing I did notice was that if I use your exact condition, it returns 'Low Stock' even though I don't have an "inventory" field at all. Not sure if a "less than" condition should return true if the field doesn't exist or there should be an error.

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