Jump to content

Recommended Posts

Posted

Confusing one, $page->index() works, but in a repeater item, looping through them and getting $item->index() returns fatal error too few arguments passed. It's using WireArray index rather than PageArray index. It's the first time I've come across this, and it's the first time I've seen an inconsistency in the API. You would imagine that both return an index value if empty. But I always thought a repeater returned a PageArray anyway? 

It might be worth I'm using the render method, so I'm unsure whether that makes it come through as a WireArray? either way, anyone know how to get the item index for a WireArray?

Posted

Repeater items should be stored in a RepeaterPageArray, which in turn extends PageArray, so this does indeed sound strange. Would need to peek into some code to say anything more, and I'm not entirely sure what "the render method" exactly means here ?

Posted

I got curious and debugged into this because I ran into a similar issue with prev() method while rendering a repeater matrix field, and had to include the 'check_access=0' selector to actually find a prev() page while a guest user visited the page, though I'm not being able to to this with index() too, like:

$page->index('check_access=0');

Maybe you can try it and see if it works for you?

  • Like 1

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