xmaverick56 Posted April 28, 2014 Share Posted April 28, 2014 I've set up a repeater field and it is working properly except that I don't know the proper syntax to get the images in the repeater field displayed. Here's what I've got so far: <? foreach($page->home_bullets as $bullet): ?> <div class="col group"> <div class="col first"><img src='{$image->url}' alt='{$image->description}'></div> <div class="col second"><span><?=$bullet->body ?></span></div> </div> <? endforeach; ?> I assume that somewhere I have to define what $images actually is (i.e. $home_bullets->images as $image) or something of the sort, but I have no idea where to do it. The repeater field only has two fields in it, images and body. Any help is greatly appreciated! Link to comment Share on other sites More sharing options...
Gayan Virajith Posted April 28, 2014 Share Posted April 28, 2014 Hi, This might be helpful to you. <?php foreach($page->home_bullets as $bullet): ?> <div class="col group"> <?php // get the very first image from images list since image field is accepting multiple images (unless you change the value of `Maximum files allowed` under Fields > images > Details tab > Maximum files allowed). $image = $bullet->images->first(); ?> <div class="col first"><img src="<?php echo $image->url; ?>" alt="<?php echo $image->description; ?>"></div> <div class="col second"><span><?=$bullet->body ?></span></div> </div> <?php endforeach; ?> Thanks Link to comment Share on other sites More sharing options...
Martijn Geerts Posted April 28, 2014 Share Posted April 28, 2014 The thing you should remember is that each item in the repeater is a Page. You should threat them as they are pages. foreach ($page->home_bullets as $bullet) <-- here bullet is the page If images is a multi image field, you can get them all with the repeater-item page. $bullet->images // all images, these can be looped. (see the page named $bullet, coming from the foreach above ) 1 Link to comment Share on other sites More sharing options...
xmaverick56 Posted April 28, 2014 Author Share Posted April 28, 2014 Thanks guys! It's working just like I had intended. 1 Link to comment Share on other sites More sharing options...
joe_ma Posted April 29, 2014 Share Posted April 29, 2014 Hello Maybe one of you could help with my problem as well? See this thread. Thanks a lot! 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