lickny2001 Posted May 28, 2018 Share Posted May 28, 2018 Im having trouble with this … i hope there’s someone out there to help. I have a bunch of pages with a multi-image (ImagesExtra module) field. My aim is to show all images from all pages in random order, accompanied with the title of the page they are on … I’m stuck on getting the page title after i’ve shuffled the array; I’m getting one and the same page title. thank you! $thumbs = new WireArray(); // get pages by template $posts = $pages->find('template=post_work’); foreach($posts as $post) { // get images, add to array foreach($post->images_extra as $thumb) $thumbs->add($thumb); } // shuffle array $random_thumbs = $thumbs->shuffle(); foreach($random_thumbs as $r) { echo "<img src='{$r->url}'> <p>$post->title</p>"; } 1 Link to comment Share on other sites More sharing options...
BitPoet Posted May 28, 2018 Share Posted May 28, 2018 A Pageimage instance knows the page it belongs to. See the bottom of the Pagefile documentation (section "Other") for reference. foreach($random_thumbs as $r) { echo "<img src='{$r->url}'> <p>{$r->page->title}</p>"; } 5 Link to comment Share on other sites More sharing options...
lickny2001 Posted May 28, 2018 Author Share Posted May 28, 2018 quite super duper ... thank you! 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