1

I've got a page which is displaying information based on a playa entry within a matrix field, when using the matrix :search parameter, this works as intended. But I need to be able to use the {count} tag. The problem is that the image thumbnails and information for each matching entry are simply looping, so the {count} just displays 1 for each of the returned results. I would like them to be 1, 2, 3, 4 etc. I have tried all the other Matrix tags, such as {row_count}, {total_rows}, {field_row_index} etc. but none of these do the job.

If any one could offer any guidance, or other ways round this, I'd be grateful. Thanks.

{exp:channel:entries channel='profile-entry' disable="member_data|pagination|categories" orderby="surname" sort="asc" dynamic="no"}
{services_new search:parent="{segment_3}"}<!-- Matrix Entry, 'parent' is the Playa column within it-->
    <!-- Playa 'related' fields that match segment_3-->
    <a href="{site_url}our-people/{url_title}" class="{if {count} == 1}col4 firstfour firstthree firsttwo {/if}{if {count} == 2}col4{/if}{if {count} == 3}col4 firsttwo{/if}">
        <img src="{profile-portrait}" alt="{title} Profile Picture" width="100%" />
        <h3>{title}</h3>
        <h3 class="title">{profile-position}</h3>
    </a>
{/services_new}
{/exp:channel:entries}
3

Are you trying to get the count of multiple playa entries for each matrix row? If so, you should be able to do something like the following, setting a different namespace prefix for matrix and playa to separate their tags:

{your_matrix_field_name var_prefix="mx"}
    Matrix row {mx:row_count} of {mx:total_rows} total rows.<br>

    {mx:your_playa_column_name var_prefix="pl"} {!-- Playa column --}
        Playa entry "{pl:title}" with count of {pl:count}.<br>
    {/mx:your_playa_column_name}

{/your_matrix_field_name}

UPDATE: Based on your code example it looks like you're counting Matrix rows, so try:

class="{if {row_count} == 1}classnames {/if} 
or
{if {row_count} == 1}class="classnames"{/if}
5
  • Hi Thanks for your response. I'm trying to use the {count} tag to switch class based on conditionals (I have already exhausted trying to use the {switch} tag.) I have tried your solution but I'm afraid this doesn't seem to be the answer. I have included my code with the original post above.
    – Erbert
    Dec 4 '13 at 10:42
  • I've updated the post - since you're counting Matrix rows {row_count} is what you want. Dec 4 '13 at 14:40
  • Hi Thanks for the update solution. Using {row_count} is returning a value of 1 for each entry that appears, even if there are 5 displayed. Rather than counting them 1,2,3,4,5 ??
    – Erbert
    Dec 5 '13 at 9:11
  • Have you tried simplifying your example down to just the absolute minimum for testing? Dec 5 '13 at 14:48
  • To a point, yes. If I take out all the if conditionals, and restrict the display to one entry field, say 'title'. even without all the extra html, if i put {title}(row_count} it still displays 1 for each entry on screen. I wondered if it might be because of the search:parent parameter, but this is necessary for the correct results to be displayed.
    – Erbert
    Dec 5 '13 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.