0

I am attempting to make a dynamic table for some of my products in ExpressionEngine.

Right now I have the table data set up as a matrix channel field type. Each of my products has 3 variations with 8 columns of specs for each variation. My question is, how can I output a specific row in a column on the front-end.

My channel fields are cell_1 - cell_8. If I put {cell_1} into a <th> it generates 3 tables with each table using a different row from that column.

Is it possible to output a specific row from a matrix column?

Thanks!

Here's an example of my current code:

<tr>
    <th>Size</th>
    <th>{cell_1} (want to call cell 1 row 1 here)</th>
    <th>{cell_1} (want to call cell 1 row 2 here)</th>
    <th>{cell_1} (want to call cell 1 row 3 here)</th>
</tr>
<tr>
    <td>Color</td>
    <td>{cell_2} (want to call cell 2 row 1 here)</td>
    <td>{cell_2} (want to call cell 2 row 2 here)</td>
    <td>{cell_2} (want to call cell 2 row 3 here)</td>
</tr>

1 Answer 1

1

Matrix has a "row_count" variable you could use, something like this:

{matrix_field}
  {if row_count == "1"}
    First row content
  {if:else}
    Remaining row content
  {/if}
{/matrix_field}

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.