Jon E Posted May 31, 2013 Posted May 31, 2013 Hi, I want to display all of the images from a page on the listing page - so for example I want the markup to be similar to: <?php include 'head.inc'; ?> <div id="portfolio_list"> <?php $features = $pages->find("template=project, sort=-date"); foreach($features as $feature) { $thumb = $feature->thumbnail ? $feature->thumbnail->width(800)->url : "http://i.imgur.com/1zxfxMW.jpg"; // if no thumbnail, replace by placeholder echo "<ul class='bxslider'>" . "<li><img src='{$thumb}' /></li> <li><img src='{$thumb}' /></li> <li><img src='{$thumb}' /></li> <li><img src='{$thumb}' /></li> </ul>" . //changed from $thumb->url to only $thumb "; } ?> </div> <?php include 'foot.inc'; ?> ...roughly. Could anyone help me out? Thanks
titanium Posted May 31, 2013 Posted May 31, 2013 bluewithoutgreen, you didn't tell us what the problem is, so I just can guess. As far as I can see, your code outputs the same thumbnail four times, and you get as many unordered lists as you have got pictures in $feature->thumbnail. I think what you really want to do is: $output = ''; // holds the HTML to output foreach($features as $feature) { $thumb = $feature->thumbnail ? $feature->thumbnail->width(800)->url : 'http://i.imgur.com/1zxfxMW.jpg'; // if no thumbnail, replace by placeholder $output .= '<li><img src="' . $thumb . '" alt="" /></li>'; } echo '<ul class="bxslider">' . $output . '</ul>'; 1
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