buster808 Posted April 19, 2019 Posted April 19, 2019 Hi, I have used a simple loop to show images in my template. How can I get this to link to a larger image possibly in a lightbox with arrows? Thanks foreach ($page->images as $image) { $content .= "<img src='{$image->url}'/>"; }
buster808 Posted April 19, 2019 Author Posted April 19, 2019 got this working foreach ($page->images as $image) { $content .= "<div uk-lightbox>"; $content .= " <a href='{$image->url}'><img src='{$image->url}'/></a>"; $content .= "</div>"; }
wbmnfktr Posted April 20, 2019 Posted April 20, 2019 <div uk-lightbox> <?php foreach($page->images as $image): ?> <a href="<?php echo $image->url; ?>" data-alt="<?php echo $image->description; ?>"> <img src="<?php echo $image->width(120)->url; ?>" alt="<?php echo $image->description; ?>"> </a> <?php endforeach; ?> </div> I'd go this way. The first DIV shouldn't be in the foreach() loop. You also want to take a closer look at the different output strategies ProcessWire provides. You are using the delayed output method which can be confusing for beginners. Look at the direct output strategy instead. That's where my example came from. https://processwire.com/docs/front-end/output/ 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