sendxt Posted July 28, 2014 Share Posted July 28, 2014 Hello, need help with output repeater field: I try to do so <?php $i = 0; foreach($page->nuoma as $field) { $i++; echo '<div class="small-12 columns large-6 columns bobkat-nuoma">'; echo '<a class="fancybox" rel="gallery1" href="'.$field->big_img->eq($i)->url.'">'; echo '<img src="' .$field->small_img->eq($i)->url. '" alt=""></a>'; echo '<h2>'.$field->bobkat_name .'</h2>'; echo $field->body; echo '<span>'.$field->price.'</span>'; echo '</div>'; } ?> For some reason I can not get the full link to pictures how to display pictures from repeater field? here is field Link to comment Share on other sites More sharing options...
Nico Knoll Posted July 28, 2014 Share Posted July 28, 2014 The image field is in your repeater so try this: <?php foreach($page->nuoma as $field) { echo '<div class="small-12 columns large-6 columns bobkat-nuoma">'; echo '<a class="fancybox" rel="gallery1" href="'.$field->big_img->eq($i)->url.'">'; echo '<img src="' .$field->small_img->first()->url. '" alt=""></a>'; echo '<h2>'.$field->bobkat_name .'</h2>'; echo $field->body; echo '<span>'.$field->price.'</span>'; echo '</div>'; } ?> This will show the first image of every repeater item. If you want to show every image from every repeater item you just have to add a second foreach inside the first foreach like: foreach($field->small_img as $image) {} 1 Link to comment Share on other sites More sharing options...
sendxt Posted July 29, 2014 Author Share Posted July 29, 2014 why this kind of links are formed? /site/assets/files/1012/ foreach($page->nuoma as $field) { echo '<div class="small-12 columns large-6 columns bobkat-nuoma">'; echo '<a class="fancybox" rel="gallery1" href="'.$field->big_img->eq(0)->url.'">'; echo '<img src="' .$field->small_img->first()->url. '" alt=""></a>'; echo '<h2>'.$field->bobkat_name .'</h2>'; echo $field->body; echo '<span>'.$field->price.'</span>'; echo '</div>'; } if doing second cycle inside, i can only take one repeater field , me need two small_img and big_img, unless there is no way how to display ? Link to comment Share on other sites More sharing options...
Nico Knoll Posted July 29, 2014 Share Posted July 29, 2014 Then you need two loops inside: <?php foreach($page->nuoma as $field) { echo '<div class="small-12 columns large-6 columns bobkat-nuoma">'; foreach($field->big_img as $big_img) { echo '<a class="fancybox" rel="gallery1" href="'.$big_img->url.'">'; } foreach($field->small_img as $small_img) { echo '<img src="' .$small_img->url. '" alt=""></a>'; } echo '<h2>'.$field->bobkat_name .'</h2>'; echo $field->body; echo '<span>'.$field->price.'</span>'; echo '</div>'; } ?> 1 Link to comment Share on other sites More sharing options...
sendxt Posted July 29, 2014 Author Share Posted July 29, 2014 thanks;) helped) 1 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