Jump to content

Repeater inside RepeaterMatrix


neophron
 Share

Recommended Posts

Hi,

I'm having trouble with a maybe simple code:

I created a repeater (gallery_logos_links) and a repeater matrix (RepeaterMatrix_unternehmen). The repeater (gallery_logos_links) is inside the matrix repeater as a matrix type.

The repeater matrix type is: gallery_logos_links and the image filed from the repeater is single_image.

 

This my code:

<?php
    foreach ($page->RepeaterMatrix_unternehmen as $item) {
      if ($item->type == 'gallery_logos_links') {
      echo "
        {foreach($item->repeater_logos_links as $logo)}
          <img src='{$logo->single_image->url}' alt='{$logo->single_image->description}' width='400'>
        {endforeach}
       ";
        } else if ($item->type == 'some_stuff') {
        echo"

 

 

Link to comment
Share on other sites

Your code can't work because interpolation for double quoted strings allows only variables or some variable expressions (like methods calls or object property access), see the documentation on string parsing. foreach loops are language constructs and can't be used inside strings. For this to work, move your foreach loop outside the echo statement and only echo the actual HTML code. Then it should work:

foreach($item->repeater_logos_links as $logo) {
	echo "<img src='{$logo->single_image->url}' alt='{$logo->single_image->description}' width='400'>";
}

 

  • Like 5
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

×
×
  • Create New...