Svet Posted May 5, 2012 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>";
diogo Posted May 5, 2012 Posted May 5, 2012 You can get a random page from an array like this: $extra = $page->child->getRandom()
Svet Posted May 5, 2012 Author 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
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