Field Tags
The following tags are available for your Matrix fields within {exp:channel:entries} tag pairs.
{my_matrix_field} .. {/my_matrix_field}
The primary tag to display your matrix field data.
Tag Parameters
- search
- Only loop through rows that match a certain criteria. Mimics the parameter for {exp:channel:entries}, and supports comparison operators<,>,<=, and>=as well.
{my_matrix_field
    search:age=">=16"}- row_id
- Only show a specific row by its ID in the exp_matrix_datatable.
 Or prefix withnotto exclude rows:
{my_matrix_field
    row_id="1|2|3"}
{my_matrix_field
    row_id="not 4|5|6"}- fixed_order
- Only show specific rows, in a specific order
{my_matrix_field
    fixed_order="3|2|1"}- orderby
- Order the rows by their column values. Separate multiple columns using the |(pipe) character.
{my_matrix_field
    orderby="session_time|session_track"}- sort
- Specifies how the column values set in orderbyshould be sorted.
 Possible values areasc,desc, andrandom.randomwill return rows in a random order.
{my_matrix_field
    sort="asc|desc|random"
    orderby="session_time"}- offset
- Skips the first X rows.
{my_matrix_field
    offset="5"
    limit="1"}- limit
- Limits the number of rows to be returned.
{my_matrix_field
    limit="1"
    offset="5"}- backspace
- Strips the last X characters from the tag output.
{my_matrix_field
    backspace="2"}
    {speaker_name},
{/my_matrix_field}- dynamic_parameters
- Set specific tag parameters "on the fly" using POST data submitted via a form.
 Mimics the parameter for{exp:channel:entries}.
{my_matrix_field
    dynamic_parameters="orderby|limit"}- var_prefix
- Tells Matrix to only parse variables that have a certain prefix.
 This is handy when you're dealing with variable name conflicts, such as if you've got a Matrix field with a Playa column pulling in entries with their own Matrix field.
{my_matrix_field
    var_prefix="spkr"}
    {!-- Playa column --}
    {spkr:favorite_bands}
        {!-- Matrix field inside band channel --}
        {albums var_prefix="albm"}
            {spkr:row_count}.{albm:row_count}
            {albm:album_title}
        {/albums}
    {/spkr:favorite_bands}
{/my_matrix_field}Tag Variables
- {row_id}
- The current row’s unique ID.
{my_matrix_field}
    {row_id}
{/my_matrix_field}- {row_count}
- The current row’s count.
{my_matrix_field}
    {row_count}
{/my_matrix_field}- {row_index}
- The current row’s index.
 This is the same as{row_count}, except it starts counting at 0 rather than 1.
{my_matrix_field}
    {row_index}
{/my_matrix_field}- {total_rows}
- The total number of rows being returned.
 For use inside tag pair. For outside, use{my_matrix_field:total_rows}
{my_matrix_field}
    {total_rows}
{/my_matrix_field}- {field_row_count}
- The current row’s count within the actual field in the CP, regardless of its position in the current tag output.
{my_matrix_field}
    {field_row_count}
{/my_matrix_field}- {field_row_index}
- The current row’s index within the actual field in the CP, regardless of its position in the current tag output.
 This is the same as{field_row_count}, except it starts counting at 0 rather than 1.
{my_matrix_field}
    {field_row_index}
{/my_matrix_field}- {field_total_rows}
- The total number of rows in the field in the CP, regardless of how many rows the current tags are outputting.
{my_matrix_field}
    {field_total_rows}
{/my_matrix_field}- {switch}
- Switch between multiple values based on the current row index.
{my_matrix_field}
    <li class="{switch='odd|even'}">
        {row_count} of {total_rows}
    </li>
{/my_matrix_field}- {prev_row} ... {/prev_row}
- Access the previous row in the field
{my_matrix_field row_id="{segment_3}"}
    {prev_row}
        <a href="/pg/{segment_2}/{row_id}">Previous</a>
    {/prev_row}
{/my_matrix_field}- {next_row} ... {/next_row}
- Access the next row in the field
{my_matrix_field row_id="{segment_3}"}
    {next_row}
        <a href="/pg/{segment_2}/{row_id}">Next</a>
    {/next_row}
{/my_matrix_field}:TABLE Tag
Matrix’s :table tag to quickly create an HTML table filled with your field’s data.
Tag Parameters
:table tag accepts all of the primary tag pair’s parameters, as well as a couple of its own:- set_row_ids
- When set to yes, addsidattributes to all <tr>'s within the <tbody>, set torow_id_followed by the row's unique ID.
{my_matrix_field
    set_row_ids="yes"}- set_classes
- When set to yes, addsclassattributes to all <th> and <td>’s, set to the column names.
{my_matrix_field
    set_classes="yes"}- set_widths
- When set to yes, addswidthattributes to all <th> and <td>’s, set to the column widths.
{my_matrix_field
    set_widths="yes"}- cellspacing
- Sets the table’s cellspacingattribute.
{my_matrix_field
    cellspacing="3"}- cellpadding
- Sets the table’s cellpaddingattribute.
{my_matrix_field
    cellpadding="5"}- border
- Sets the table’s borderattribute.
{my_matrix_field
    border="2"}- width
- Sets the table’s widthattribute.
{my_matrix_field
    width="300"}- class
- Sets the table’s classattribute.
{my_matrix_field
    class="highlight"}:PREV_ROW and :NEXT_ROW Tags
Access the previous or next row in your field, from a given starting point. The starting point is whatever the first row would be with your declared field parameters.
Tag Parameters
:prev_row and :next_row tags accept all of the primary tag pair’s parameters.{gallery:next_row row_id="{segment_3}"}
    Up next:
    <a href="/pg/{segment_2}/{row_id}">{p_title}</a>
{/gallery:next_row}:TOTAL_ROWS Tag
Returns the total number of rows in your Matrix field.
NOTE: Only works outside your tag pair. For inside your tag pair, use the {total_rows} or {field_total_rows} tags.
Tag Parameters
:total_rows tag accepts all of the primary tag pair’s parameters.{if {my_matrix_field:total_rows} >= 5}
    We’ve got {my_matrix_field:total_rows} speakers!
{/if}:AVERAGE, :LOWEST, :HIGHEST, and :SUM Tags
These tags return the average, lowest, highest, or sum value of a given numeric column in your Matrix field.
Tag Parameters
:average, :lowest, :highest, and :sum tag accepts all of the primary tag pair’s parameters, as well as a couple of their own:- col required- The name of the column you wish to get info about. (Required)
{my_matrix_field:average col="age"}- decimalsDefault 0
- The number of decimal points the number should have.
 {my_matrix_field:average decimals="2"}- dec_pointDefault . (period)
- The character that will be used for the decimal.
 {my_matrix_field:average dec_point="."}- thousands_sepDefault , (comma)
- The character that will be used as the thousands separator.
 {my_matrix_field:average thousands_sep=","}
Support
Having problems setting up and/or using Matrix? Support is offered from 10am to 4pm EST weekdays. Send us an email at help@eeharbor.com and we will respond as quickly as we can.
