Jump to content

getting page title after images shuffle from multiple pages


lickny2001
 Share

Recommended Posts

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>";
    }

 

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...