Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
Hello again.

Im trying to setup a gallery and Iv ran in to an issue. I have a gallery for my portfolio that im turning in to couch. The gallery has code that looks like this

Code: Select all
<!-- 1-4 -->
<div>
<img src="http://farm1.static.flickr.com/143/321464099_a7cfcb95cf_t.jpg" />
<img src="http://farm4.static.flickr.com/3089/2796719087_c3ee89a730_t.jpg" />
<img src="http://farm1.static.flickr.com/79/244441862_08ec9b6b49_t.jpg" />
<img src="http://farm1.static.flickr.com/28/66523124_b468cf4978_t.jpg" />
</div>
<!-- 5-8 -->
<div>
<img src="http://farm1.static.flickr.com/79/244441862_08ec9b6b49_t.jpg" />
<img src="http://farm4.static.flickr.com/3089/2796719087_c3ee89a730_t.jpg" />
<img src="http://farm1.static.flickr.com/28/66523124_b468cf4978_t.jpg" />
<img src="http://farm1.static.flickr.com/143/321464099_a7cfcb95cf_t.jpg" />
</div>


What im trying to do is turn this in to a repeatable element. I have the code for that done, but the problem Im having is with the DIV that holds the 1st group and 2nd group of images. I need to make it so that for the first for images that are held it puts them in to a group with that div,
the next 4 puts it in to the next group... so on and so on.

Any ideas...?

If you need to look at the site to get a better idea of what im trying to do check this page out... http://costellocoding.com/portfolio_single.html

Thanks,
Steven Costello
Costello Coding
Hi Stephen

What you need is a count for the repeatable region to cycle through every four images and open / close <divs> for the thumbs carousel right?

I think you'd want to do something with modulus I think, I've done his in Wordpress before but not couch.

Code: Select all
<cms:if k_count % 4== 0 >



now note that won't work I tried using the % and couch didn't like it, plus I am not 100% how to structure the conditional for the repeatable - I'm sure KK or Cheesypoof can shed some light
As @patrickvibes said, we need to use the modulo (remainder) operation. This should do what you want:
Code: Select all
<cms:show_repeatable 'pictures'>
   <cms:set num = "<cms:mod k_count '4'/>"/>
   <cms:if num == '1'>
      <div>
   </cms:if>
   <img src="<cms:show image/>"/>
   <cms:if num == '0' || k_count == k_total_records>
      </div>
   </cms:if>
</cms:show_repeatable>
Awesome that worked perfectly. Really do appreciate all your guys help with this.

Thanks,
Steven Costello
Costello Coding
Great stuff @cheesypoof I sandboxed that little snippet for future reference, glad Stephen is sorted, you rock
5 posts Page 1 of 1