Svet Posted May 5, 2012 Share Posted May 5, 2012 Hi all, Wrote this code to get one random child page and display the first image on it. However, it is not working right. With this I always get the last child page in the array, and I want anything else but that! $extra = $page->child("sort=random"); $thumb = $extra->images[0]; $thumb = $image->size(140, 95); echo "<a href='{$extra->url}'><img src='{$thumb->url}' border='0'></a>"; Link to comment Share on other sites More sharing options...
diogo Posted May 5, 2012 Share Posted May 5, 2012 You can get a random page from an array like this: $extra = $page->child->getRandom() Link to comment Share on other sites More sharing options...
Svet Posted May 5, 2012 Author Share Posted May 5, 2012 Topic closed. Not to use this forum as a brain dump place, but since I cannot delete this posting, I am just going to say this: be careful about reusing the variable names, even outside of the loop, because otherwize you will end up like me, asking stupid questions lol Link to comment Share on other sites More sharing options...
diogo Posted May 5, 2012 Share Posted May 5, 2012 The $extra wasn't really an extra? 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