Support

Account

Home Forums Add-ons Repeater Field FOR EACH Inside of an IF/ELSE using Select Field/Repeater Reply To: FOR EACH Inside of an IF/ELSE using Select Field/Repeater

  • Thank you so much! That worked!!! I really appreciate it!

    This code has brought up one other question – is it possible to add a conditional within the repeater. Is there a specific syntax to be used?

    I have tried multiple ways of writing it with no luck.

    <?php 
    		foreach ($section['testimonials'] as $item => $block) :
    	?>
    		<div class="testimonial-slideshow__slide background-cover">
    			<div class="testimonial-slideshow__slide-content">
    				<?=$block['testimonial_text']?>
    				<h5>- <?=$block['testimonial_attribution']?></h5>
    
    				<?php if ($block['testimonial_image'] !== '') : ?>
    					<div class="testimonial-image"><img src="<?=$block['testimonial_image']['sizes']['image-90-90']?>"/></div>
    				<?php endif; ?>
    
    				<?php if ($block['button_url'] !== '') : ?>
    					<a href="<?=$block['button_url']?>" class="caps outline button" ><?=$block['button_text']?></a>
    				<?php endif; ?>
    			</div>
    		</div>
    	<?php endforeach; ?>

    Oddly the button stays hidden but the testimonial_image circle div doesn’t stay hidden.