SebastianP Posted July 27, 2019 Share Posted July 27, 2019 Hi, I have a repeater which contains some text fields and one FieldsetPage field with own fields. In this FieldsetPage field I want so show/hide one of the fields in addiction of the depth of the parent repeater element. I have tried to set the "show only if" property to "parent.depth=1" and "parent.parent.depth=1", unfortunately without success. Is there the possibility to do this? Thank you for any hint or suggestion! Regards Sebastian Link to comment Share on other sites More sharing options...
dragan Posted July 27, 2019 Share Posted July 27, 2019 (edited) Did you try https://processwire.com/api/ref/page/num-parents/ ? edit: Actually, no. I was confused - the above seems to work with Matrix Repeaters, for regular repeaters depth should work. Edited July 27, 2019 by dragan clarification Link to comment Share on other sites More sharing options...
dragan Posted July 27, 2019 Share Posted July 27, 2019 I don't know if this helps, but in a simple test setup I got this to work: In the field settings "show only if..." > show only if custom PHP returns true: $rep = $page->textblocks; $c = $rep->count() -1; $last = $rep->$c; if($last->depth > 2) { return true; } Basically, I check the number of entries in a repeater called textblocks, then get the last (deepest) one, and check if depth is bigger than 3 (2, since it's zero-based). Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now