Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
Got another thing I need help with. I tried messing with his for the last 2 days, but I cant seem to figure out how to do this.

I have a portfolio list page that lists all of the items in my portfolio. The problem im having is a 2 part problem. every third item has a class assigned to it called last, and also at the end of the block has a clear div. I cant figure out how to make it so every third item has this.

Here is a code block of the portfolio item
Code: Select all
<cms:pages masterpage="portfolio.php">
<div class="one-third portfolio-box">
<a href="images/portfolio1.png" title="Stylez" class="thumb loader" rel="lightbox[gallery]">
<span class="enlarge">
<img src="images/portfolio1-thumb.jpg" alt="Sample Portfolio Item" class="pretty" />
</span>
</a>
<h2><a href="portfolio_single.html" title="">Stylez</a></h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.</p>
<p>
<a href="portfolio_single.html" title="Learn More" class="button">
<span class="left">
<span class="right">
<span class="middle">Learn More</span>
</span><!-- .right (end) -->
</span><!-- .left (end) -->
</a><!-- .button (end) -->
</p>
</div><!-- .portfolio-box (end) -->
</cms:pages>


If you need to get a better example take a look at this page.
http://costellocoding.com/portfolio.html

Thanks,
Steven Costello
Costello Coding
Hi Steven,

The solution given by @cheesypoof (viewtopic.php?f=4&t=7455) involving the use of cms:mod tag can be easily modified to output the classname and the div every third iteration.

What I am mentioning here is another solution that uses cms:zebra tag (you can find more info about this tag at
http://www.couchcms.com/docs/tags-reference/zebra.html)

You need an output similar to the following where every third item has some additional data-
Code: Select all
<!-- ROW 1 -->
<div class="one-third portfolio-box">

</div>
<div class="one-third portfolio-box">

</div>
<div class="one-third last portfolio-box">

</div>
<div class="clear"></div>

<!-- ROW 2 -->
<div class="one-third portfolio-box">

</div>
<div class="one-third portfolio-box">

</div>
<div class="one-third last portfolio-box">

</div>
<div class="clear"></div>

We can get it using the following code -
Code: Select all
<cms:pages masterpage='sometemplate.php' >
    <div class="one-third <cms:zebra '' '' 'last ' />portfolio-box">
       
    </div>   
    <cms:zebra '' '' '<div class="clear"></div>' />
</cms:pages>

We are using two cms:zebra tags above to output blank ('') for iteration number 1 and 2, while for iteration number 3 we make them output the additional text (class and div).

Hope this helps.
Sweet, that worked perfectly.

Thanks,
Steven Costello
Costello Coding
3 posts Page 1 of 1
cron