Alex Posted May 17, 2012 Share Posted May 17, 2012 Hi, I'm displaying an image on the homepage from a group of sub pages which all use the same template. I can display the image fine, and it is random. I can't work out how to get the image to link to it's page? My code below when you click the image it just keeps cycling through the random images. $image = $pages->get("template=artworks-child, sort=random")->artworks_thumb->getRandom(); $thumb = $image->size(550, 0); echo "<a href='{$page->url}'><img src='{$thumb->url}'></a>"; Link to comment Share on other sites More sharing options...
diogo Posted May 17, 2012 Share Posted May 17, 2012 store the page in a variable, and get the image only later: $randomPage = $pages->get("template=artworks-child, sort=random"); $image = $randomPage->artworks_thumb->getRandom(); $thumb = $image->size(550, 0); echo "<a href='{$randomPage->url}'><img src='{$thumb->url}'></a>"; 1 Link to comment Share on other sites More sharing options...
Alex Posted May 18, 2012 Author Share Posted May 18, 2012 thanks Diogo, I get it now 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