mindplay.dk Posted June 24, 2013 Posted June 24, 2013 I have a Template that has a field with a list of images. To my surprise, the image list returns two different things when accessing the images in two different ways: <?php var_dump($page->images->first()); // => Pageimage var_dump($page->images[0]); // => Page Is this deliberate? It seems really inconsistent and, well, weird...
ryan Posted June 27, 2013 Posted June 27, 2013 WireArray implements PHP's ArrayAccess interface, so actually the something like $images[0] ideally would work. The reason for the inconsistent behavior is that images are indexed by filename, not by number. So $images['filename.jpg'] would be the actual ArrayAccess implementation. However, I think I could find a way to make it work by re-implementing the offsetGet() method in the Pagefiles and having it do a slice() to return a specific index. Thanks for reporting it! 2
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