We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

NEED HELP with FF matrix/nGen with count variable

Development and Programming

glogurl's avatar
glogurl
13 posts
16 years ago
glogurl's avatar glogurl

below is my code for my list that will be displaying images, 4 to a row two rows max. I need a class of “last” for the 4th and 8th li. please help as what i have here is not working. I’m currently using the FF Matrix with nGen

<h2>Photos</h2>
                
<ul>                
                    
{sub-photos}
                                                    
     <li class="detailsImages002 {if count == "4" OR count == "8"}last{/if}">
{exp:imgsizer:size src="{sub-photo}" width="125" height="83" alt="{title}"}</li>
                    
{/sub-photos}
                
</ul>
       
stinhambo's avatar
stinhambo
1,268 posts
about 16 years ago
stinhambo's avatar stinhambo

Have you tried taking out the quotes and use {row_count}?

{if row_count == 4 OR row_count == 8}
       
stinhambo's avatar
stinhambo
1,268 posts
about 16 years ago
stinhambo's avatar stinhambo

Some experimenting has shown that row_count start from 0 so you will need -

[if row_count == 3 OR row_count == 7}

In fact you can use this same principal to control your header (in case there are no entries)

{sub-photos}

{if row_count == 0}
<h2>Photos</h2>
<ul>
{/if}

    <li class="detailsImages002{if count == 3 OR count == 7} last{/if}">
    {exp:imgsizer:size src="{photo-img}" width="125" height="83" alt="{photo-title}"}
    </li>

{if row_count == total_rows}
</ul>
{/if}

{/sub-photos}

Some things to note:

  1. Add the space for the class within the if statement. That way there won’t be a space if those conditions aren’t met.
  2. I changed the image and title variable names as you said you were using the Matrix fieldtype so you wouldn’t use the fieldname but instead the cell names.

Let me know if this doesn’t make sense.

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
15 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team

In my use I’ve noticed that you need to wrap total_rows and row_count in curly braces when testing against a conditional. For example:

[if {row_count} == 3 OR {row_count} == 7}
       
stinhambo's avatar
stinhambo
1,268 posts
15 years ago
stinhambo's avatar stinhambo

Cheers Erik 😊

       
metadaptive's avatar
metadaptive
96 posts
15 years ago
metadaptive's avatar metadaptive

cheers Erik! that had me tearing my hair out until I found this post…

       
pixelpie's avatar
pixelpie
11 posts
15 years ago
pixelpie's avatar pixelpie

Thanks Erik!

A headache less finding your reply!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.