jeremie Posted August 22, 2024 Share Posted August 22, 2024 (edited) Hi, I'm very new to processwire and programming in general, but love to play with it. On a page of my personal website listing my fav artists, I have this code Quote <div class="w3-container w3-third" style="max-width:400px"> <?php $items = $pages->find("template=artist"); foreach ($items as $item){ $thumb = $item->images->first()->size(300,300); echo "<div class='w3-card w3-margin jegreen' style='display:inline-block'> <a href='$item->url'> <img src='$thumb->url' alt='Too Bad' style='width:50%'> <div class='w3-container'> <h5>$item->title</h5> <p>$item->body</p> </div> </a> </div> <hr> "; } ?> </div> it works great, but it is sorting the "artist's containers" from the first I enter to the last. I've tried to replace "first" by "last" but it is changing the image chosen for the container, not the order of appearance. Then I add Quote <?php $items = $pages->find("template=artist", "sort=-date"); but I didn't notice any change Can someone help me out. Thanks a lot Edited August 22, 2024 by jeremie Link to comment Share on other sites More sharing options...
Gideon So Posted August 22, 2024 Share Posted August 22, 2024 Hi @jeremie May be <?php $items = $pages->find("template=artist", "sort=-sort"); Gideon Link to comment Share on other sites More sharing options...
jeremie Posted August 22, 2024 Author Share Posted August 22, 2024 (edited) Hi @Gideon So, doesn't seem to work, and "sort=-created" neither, but thanks for the help Edited August 22, 2024 by jeremie Link to comment Share on other sites More sharing options...
Gideon So Posted August 22, 2024 Share Posted August 22, 2024 Hi @jeremie Then try this: <?php $items = $pages->find("template=artist")->reverse(); https://processwire.com/api/ref/wire-array/reverse/ Gideon 1 Link to comment Share on other sites More sharing options...
jeremie Posted August 22, 2024 Author Share Posted August 22, 2024 works like a charm. thanks a lot @Gideon So 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