Jump to content

Output From Repeater Field


sendxt
 Share

Recommended Posts

Hello, need help with output repeater field:
 
12jpg_3968103_13174324.jpg
 
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

post-2382-0-11085800-1406568489_thumb.pn

Link to comment
Share on other sites

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) {}

  • Like 1
Link to comment
Share on other sites

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

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>';

}

?>
  • 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...