I'm using Matrix, and the row_id tag parameter isn't working for me. At the moment I am on relying on the search Tag Parameter.

This doesn't work:

{technical_specifications row_id="1"}{spec_value}{/technical_specifications}

Whilst this works:

{technical_specifications search:spec_label="Width"}{spec_value}{/technical_specifications}

Screenshot of field setup in an entry

What am I doing wrong?

  • Can you check to make sure your code examples are in the correct place in your question? It seems they are flipped. – Anna_MediaGirl Jan 14 '13 at 17:44
  • 1
    @Anna_MediaGirl, I have corrected my original question - thanks – Abs Jan 14 '13 at 17:48

Row IDs in Matrix are unique for the whole site, like entry IDs. So there only will ever be one row with a row_id of '1' – the first row you ever created. If you’ve deleted that row, then no row exists with the ID '1' anymore.

If you just want to grab the first row, use limit="1" instead, which will limit the output to only the first row.

If you want to grab the second row, you would use limit="1" as well as offset="1", etc..

Both of those parameters are documented on http://pixelandtonic.com/matrix/docs/templates.

| improve this answer | |
  • Thanks for the reply. I thought row ids was in relation to that specific entry. In that case, I will leave it using the search paramter. Is there any Performance difference between your solution and mine? Which is quicker? – Abs Jan 14 '13 at 17:43
  • And is there a way to find out the row id for a particular row? – Abs Jan 14 '13 at 17:50
  • Well, limit="1" is quicker, since it translates to a simple LIMIT 1 in the SQL query, whereas search:spec_label="Width" is going to perform a search on an unindexed column (though you can add the index yourself ;). However considering that the Width column may change positions from entry to entry, or might not be there at all (never trust authors!), search:spec_label is a better way to go in your case. Change the value to "=Width" so at least it’s not a LIKE search. – Brandon Kelly Jan 14 '13 at 17:50
  • You can get the row_id for a particular row using the {row_id} variable within your Matrix tag pair. Useful if you want to pass it to another template, or include it in the URL, etc.. – eventually to be passed into row_id="{embed:row_id}" or row_id="{segment_4}". – Brandon Kelly Jan 14 '13 at 17:53

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.