Jump to content
ryan

PW 3.0.126 – Core updates

Recommended Posts

Hi Ryan,

Great update I can see me using this often - is there any plan to bring this to repeaters? 

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Soo, erm, I was running 3.0.125 😂 Sorry guys. 

  • Like 1
  • Haha 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...