Robert Zelník Posted June 7, 2012 Share Posted June 7, 2012 I would like to create a simple image gallery using simple image field with multiple images per page. I would like to show them sorted (newest first). I have tried this: $images = $page->images->find("sort=-id"); foreach ($images as $image): ... endforeach; It works well with child pages, but it seems like it doesn't work with image fields. Is there any way to sort these images, or should I use repeatable fields instead? Link to comment Share on other sites More sharing options...
apeisa Posted June 7, 2012 Share Posted June 7, 2012 Isn't the default sort oldest first? Then you should get newest first just reversing the order (of course assuming you haven't changed the order): $images = $page->images->reverse(); Other WireArray methods: http://processwire.com/api/arrays/ 3 Link to comment Share on other sites More sharing options...
Robert Zelník Posted June 7, 2012 Author Share Posted June 7, 2012 Yes, that's it, it works well. Thanks... 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