Jump to content

Recommended Posts

Posted

Hi folks,

I am building a 'logo' list of supporters/clients. I have two slides and would like to show different ones on each slide, but work with a single repeater on the page. There is two checkboxes within the repeater when adding a logo ('created_for' and 'helped_create').

I thought this code below would work in returning ONLY those 'repeater rows' which has the 'created_for' checkbox checked, but it's still including the logos that have the 'helped_create' checkbox checked too. I think I may have my foreach loops mixed? Any thoughts?

<?php $created_for = $pages->find('wwww_slider.created_for=1'); ?>
<div class="each-icon-container">
<?php foreach ($created_for as $created) : ?>
<?php foreach ($created->wwww_slider as $icon) : ?>
<div class="each-icon">
<?php if ( $icon->link ) : ?><a href="<?php echo $icon->link; ?>"><?php endif; ?><img src="<?php echo $icon->logo_off_state->url; ?>" /><?php if ( $icon->link ) : ?></a><?php endif; ?>
</div>
<?php endforeach; ?>
<?php endforeach; ?>
</div>

Thanks in advance,

R

 
Posted

The problem you're strugling with is keeping repeaters and pages seperate. You're searching for pages with at least one repeater item, which has created_for checked. 

You either need to only search for repeaters

$repeaters = $pages->find("template=repeater_wwww_slider, created_for=1, include=all"); // repeaters are hidden by default
foreach($repeaters as $icon){}

or you need to check in the foreach if the current repeater's checkbox is checked.

$somepages = $pages->find("selector for your pages with repeater");
foreach($somepages as $somepage){
  foreach($somepage->wwww_slider as $icon){
    if($icon->created_for == 0) continue;
    // Your stuff
  }
}
  • Like 1

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
×
×
  • Create New...