3

I need to know outside of the Matrix tag pair the total rows that it has. To get total rows within the tag pair, this works for me:

{matrix_field_short_name}
   <h1>{total_rows}</h1>
{/matrix_field_short_name}

Outside the tag pair, it seems like this should work: {matrix_field_short_name:total_rows} per http://pixelandtonic.com/matrix/docs/templates. However, instead of getting an integer, I'm getting the string http://domain.com/member_uploads/_s:total_rows/slide.jpg.

My Matrix field is names images and it contains the columns image (the file) and caption (a text field).

Any idea what might be going on?

EDIT 1: Code Snippet

<h1>{images:total_rows}</h1>                        

{images}                                            
    <div class="{if row_count == 1}active{/if} item">
        <img src="{image:250x250}" alt="{caption}"/>
    </div>
    <div class="carousel-caption">
        <p>{caption}</p>
    </div>  
{/images}
7
  • it should work, able to provide additional code from within your template?
    – Tad Ward
    Jan 4, 2013 at 2:01
  • See edit. Everything in {images} works as expected. I don't get total rows in the h1. Jan 4, 2013 at 2:19
  • what does your exp:channel:entries tag look like? is the above code the only thing in the template? I assume latest version of matrix, tried re-uploading?
    – Tad Ward
    Jan 4, 2013 at 2:38
  • It looks like a conflict with names. I'd try renaming your matrix field to something else.
    – Tyssen
    Jan 4, 2013 at 2:48
  • yeah I'd say name conflict is the most probably, go with a strict or firm naming convention for you fields ala digitalevangelist.net/notes/whats-in-a-name Jan 4, 2013 at 2:50

1 Answer 1

3

I agree with the name. I've run into that before. I have adapted a matrix naming convention of a small prefix from the matrix field then whatever I need : eg. seg-images if the matrix field is segments. In your case, it looks like you have images as the matrix field itself. Try naming it something like mx-images.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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