BoldMinded Docs
  • Overview
  • Advanced Categories
    • Docs
      • Installation
      • Requirements
      • Setup & Configuration
        • Hidden Config Options
        • Multi-Site Manager
      • Template Tags
      • FAQs
  • Ansel
    • Docs
      • Installation
      • Upgrading
      • Requirements
      • Settings
      • Usage
        • Channel:Form
      • Troubleshooting
      • Template Tags
    • FAQs
  • Bloqs
    • Docs
      • Why Bloqs?
      • Features
        • Add Bloq Menu
        • Nesting
        • Cloning
        • Drafts
        • Bloq Usage
        • Deprecated Bloqs
        • Caching
        • Profiling
        • Bloq Components
        • Bloq Groups
      • Installation
      • Requirements & Compatibility
      • Setup & Configuration
        • Hidden Config Options
      • Creating Bloqs
      • Template Tags
        • Twig
        • Examples
      • Context Variables
      • Add-on Developers
    • FAQs
  • Carson
    • Docs
      • Installation
      • Requirements
      • Fields
        • Omni
          • Hidden Config
        • Assistant
        • SEO
      • Troubleshooting
  • Custom System Messages
    • Docs
      • Installation
      • Requirements
      • Variables
      • Template Tags
  • DataGrab
    • Docs
      • Installation & Upgrading
      • Requirements
      • Troubleshooting
      • Configuring Imports
      • Running Imports
      • Automatic Imports
        • Importing with cron
        • Importing with cron (Deprecated)
      • Endpoints
      • Configuration Options
        • Config File Options
        • Increasing PHP memory limit
      • Import Types
        • CSV
          • Importing into Grid or Matrix field
        • JSON
          • Example file
        • WordPress
        • XML
          • Example file
        • Creating your own import type
      • Assigning Authors
      • Field Types
        • Assets
        • Ansel
        • Bloqs
        • Calendar
        • Channel Images
        • Date
        • File
        • File Grid
        • Fluid
        • Grid
        • Low Events
        • Relationships
        • Simple Grids & Tables
        • Tag & Tagger
        • Matrix (Deprecated)
        • Creating your own fieldtype
      • Publisher
      • Version 5.0
      • Version 6.0
    • FAQs
  • Feature Flags
    • Docs
      • Installation & Upgrading
      • Requirements
      • Configuration
      • Template Tags
      • A/B Testing
    • FAQs
  • Fluidity
    • Docs
      • Installation & Upgrading
      • Requirements
      • Configuration
      • Demos
    • FAQs
  • Logit
    • Docs
      • Installation
      • Requirements
      • Configuration
    • FAQs
  • Publisher
    • Docs
      • Installation
      • Requirements
      • Issues & Tips
      • Languages
      • Template Tags
        • Forms
        • Email Notification Templates
        • Channel:Form
        • Twig
      • URL Translations
      • Auto Translations
      • Diffs
      • Drafts
      • Categories
      • Phrases
      • Persistence
      • Performance
      • Add-ons
        • First Party
        • Third Party
      • Hidden Config
      • Extending Publisher
    • FAQs
  • Reading Time PRo
    • Docs
      • Installation
      • Requirements
      • Configuration
      • Template Tags
  • Reel
    • Docs
      • Installation
      • Requirements
      • Settings
      • Field Tags
    • FAQs
  • Simple Grids & Tables
    • Docs
      • Installation
      • Requirements
      • Template Tags
      • CSV File Imports
      • Field Settings
      • GraphQL
      • Advanced Configuration (deprecated)
    • FAQs
  • Sitemap
    • Docs
      • Installation
      • Requirements
      • Configuration & Usage
    • FAQs
  • Snaptcha
    • Docs
      • Installation
      • Requirements
      • Configuration
      • Template Tags
      • Developers
    • FAQs
  • Speedy
    • Docs
      • Installation & Updating
      • Requirements
      • Configuration
      • Template Tags
      • Static Caching
        • Real World Example
      • Frontedit Support
      • Control Panel
      • Migrating from CE Cache
      • Diagnostics
      • CLI Commands
      • Reverse Proxy Purging
    • FAQs
  • Trek (unreleased)
    • Docs
      • Configuration
    • FAQs
  • Queue
    • Docs
Powered by GitBook
On this page
  • Variables
  • Parameters
  • Template Code Examples
  • Heading Rows
  • Simple Table (standalone)
  • Simple Table (inside Grid)
  • Simple Table (inside of Fluid)
  • Simple Table (inside Bloqs)
  • Simple Table (as a Pro Variable)
  • Simple Grid (standalone)
  • Simple Grid (inside Grid)
  • Simple Grid (as a Low Variable)
  • Date and Date with Timezone fields
  • File fields

Was this helpful?

  1. Simple Grids & Tables
  2. Docs

Template Tags

Variables

The following variables are available in both Simple Table and Simple Grid tag pairs.

{row_id}
{total_rows}
{total_columns}
{count}
{index}
{heading_row}
{is_first_row}
{is_last_row}
{switch="a|b"}

Parameters

  • prefix="" The prefix parameter is no longer necessary for Simple Grid fields as of version 1.7. It is deprecated and may not work as expected . It still works in Simple Table fields.

  • backspace=""

Template Code Examples

Heading Rows

As of version 1.5 of Simple Grids & Tables you can optionally enable adding a Heading Row button to each grid or table field. When a Heading Row is added it will span all columns in the grid or table field, which requires slightly different rendering behavior in the template. The Heading Row variable name can not be changed and it's behavior is the same in both a Simple Grid and Simple Table field, thus the following template logic can be used when rendering either field in the template.

<table>
{simple_table_or_grid_field}
    {if heading_row}
        <tr switch="{switch='odd|even'}">
            <th colspan="{total_columns}">{heading_row}</th>
        </tr>
    {if:else}
        // render columns as noted in examples below
    {/if}
{/simple_table_or_grid_field}
</table>

Simple Table (standalone)

Note you can optionally prefix all of Simple Grid and Simple Table field variables with the prefix="" parameter.

Since Simple Table does not have named columns, all of the column values are available with the {value} variable. The {column_heading} variable will print the column values from the first row for every row in the loop. If you're using the first row as a heading, then this variable can be useful to improve accessibility, or simply having to not hard-code the value of the first row in your templates.

{exp:channel:entries channel="grids" entry_id="1"}
    <table>
    {simple_table_field prefix="st:"}
        <tr data-id="{st:row_id}" class="{switch='odd|even'}">
            {st:columns}
                {if st:is_first_row}
                    <th data-id="{st:column_id}">
                        {st:value} or {st:column_heading}
                    </th>
                {if:elseif st:is_last_row}
                    <td data-id="{st:column_id}">
                        <span aria-hidden="true">{st:column_heading}: </span><i>{st:value}</i>
                    </td>
                {if:else}
                    <td data-id="{st:column_id}">
                        <span aria-hidden="true">{st:column_heading}: </span>{st:value}
                    </td>
                {/if}
            {/st:columns}
        </tr>
    {/simple_table_field}
    </table>
{/exp:channel:entries}
{% for entry in exp.channel.entries({channel: 'grids', entry_id: 26611}) %}
    <table>
    {% for row in entry.simple_table_field %}
        <tr data-id="{{ row.row_id }}" class="{{ cycle(['odd', 'even'], loop.index0) }}>
        {% for column in row.columns %}
            {% if row.is_first_row %}
                <th data-id="{{ column.column_id }}">
                    {{ column.value }} or {{ column.column_heading }}
                </th>
            {% elseif row.is_last_row %}
                <td data-id="{{ column.column_id }}">
                    <span aria-hidden="true">{{ column.column_heading }}: </span><i>{{ column.value }}</i>
                </td>
            {% else %}
                <td data-id="{{ column.column_id }}">
                    {{ column.value }}
                </td>
            {% endif %}
        {% endfor %}
        </tr>
    {% endfor %}
    </table>
{% endfor %}

Simple Table (inside Grid)

{grid_field}
    <table>
    {grid_field:simple_table_field}
        <tr class="{switch='odd|even'}">
            {columns}
                {if is_first_row}
                    <th data-id="{column_id}">
                        {value}
                    </th>
                {if:elseif is_last_row}
                    <td data-id="{column_id}">
                        <i>{value}</i>
                    </td>
                {if:else}
                    <td data-id="{column_id}">
                        {value}
                    </td>
                {/if}
            {/columns}
        </tr>
    {/grid_field:simple_table_field}
    </table>
{/grid_field}

Simple Table (inside of Fluid)


{fluid_field}
    {fluid_field:simple_table_field}
        <table>
            {content prefix="st:"}
            <tr>
                {st:columns}
                    {if is_first_row}
                        <th data-id="{st:column_id}">
                            {st:value}
                        </th>
                    {if:elseif is_last_row}
                        <td data-id="{st:column_id}">
                            <i>{st:value}</i>
                        </td>
                    {if:else}
                        <td data-id="{st:column_id}">
                            {st:value}
                        </td>
                    {/if}
                {/st:columns}
            </tr>
            {/content}
        </table>
    {/fluid_field:simple_table_field}
{/fluid_field}

Simple Table (inside Bloqs)

{bloqs_field}
    {block}
        {simple_table_field}
            <tr switch="{switch='odd|even'}">
                {columns}
                    {if is_first_row}
                        <th data-id="{column_id}">
                            {value}
                        </th>
                    {if:elseif is_last_row}
                        <td data-id="{column_id}">
                            <i>{value}</i>
                        </td>
                    {if:else}
                        <td data-id="{column_id}">
                            {value}
                        </td>
                    {/if}
                {/columns}
            </tr>
        {/simple_table_field}
    {/block}
{/bloqs_field}

Simple Table (as a Pro Variable)

{exp:pro_variables:pair var="lv_simple_table" prefix="st:"}
    <table>
        <tr data-id="{st:row_id}" class="{switch='odd|even'}">
            {st:columns}
                {if st:is_first_row}
                    <th data-id="{st:column_id}">
                        {st:value}
                    </th>
                {if:elseif st:is_last_row}
                    <td data-id="{st:column_id}">
                        <i>{st:value}</i>
                    </td>
                {if:else}
                    <td data-id="{st:column_id}">
                        {st:value}
                    </td>
                {/if}
            {/st:columns}
        </tr>
    </table>
{/exp:pro_variables:pair}

Simple Grid (standalone)

Unlike Simple Table, Simple Grid does have named columns. The column labels or headings are defined in the control panel, thus there is no need for a {column_heading} variable. In this case the column names are {product} and {price}. Simple Grid operates very similarly to the native Grid field, but does not have variable modifiers such as :sum or :average.

Any tag pairs inside of a Simple Grid field need to be prefixed with the Simple Grid field name. For example:

{my_simple_grid_field} {my_simple_grid_field:my_file_field} {url} {/my_simple_grid_field:my_file_field} {/my_simple_grid_field}

Prefixing is not required when using Twig or Blade.

{exp:channel:entries channel="grids" entry_id="1"}
    {simple_grid_field}
    
        {!-- If you're using Heading Rows, wrapping it in a conditional may 
        be helpful. If not, you can ignore this conditional. --}
        
        {if heading_row}
            <h2>{heading_row}</h2>
        {if:else}
            {product}
            {price}
            {summary}
            
            {!-- Regardless of the column names you define, you'll also have 
            access to each of these variables while iterating the Grid rows --}
            
            {count}
            {row_count}
            {row_id}
            {total_rows}
            {total_columns}
            {index}
            {row_index}
            {is_first_row}
            {is_last_row}
        {/if}
        
    {/simple_grid_field}
{/exp:channel:entries}
{% for entry in exp.channel.entries({channel: 'grids', entry_id: 1}) %}
    {% for row in entry.simple_grid_field %}
        
        {# If you're using Heading Rows, wrapping it in a conditional may be helpful.
        If not, you can ignore this conditional. #}
        
        {% if row.heading_row %}
            <h2>{{ row.heading_row }}</h2>
        {% else %}
        
            {# Each column in the Simple Grid field is accessible via it's short name. 
            In this example the Simple Grid field has 3 columns: Product, Price, and an RTE Summary field #}
            
            {{ row.product }}
            {{ row.price }}
            {{ row.summary | raw }}
            
            {# Regardless of the column names you define, you'll also have access 
            to each of these variables while iterating the Grid rows #}
            
            {{ row.count }}
            {{ row.row_count }}
            {{ row.row_id }}
            {{ row.total_rows }}
            {{ row.total_columns }}
            {{ row.index }}
            {{ row.row_index }}
            {{ row.is_first_row }}
            {{ row.is_last_row }}
            
        {% endif %}
        
    {% endfor %}
{% endfor %}

Simple Grid (inside Grid)

{grid_field}
    {grid_field:total_rows}
    <table>
    {grid_field:simple_grid_field}
        <tr switch="{switch='odd|even'}" data-total-rows="{total_rows}">
            <th>{product}</th> <!-- This is a column name in the Simple Grid field -->
            <td>{price}</td> <!-- This is a column name in the Simple Grid field -->
        </tr>
    {/grid_field:simple_grid_field}
    </table>
{/grid_field}

Simple Grid (as a Low Variable)

{exp:low_variables:pair var="lv_grid_field"}
    <table>
        <tr switch="{switch='odd|even'}" data-total-rows="{total_rows}">
            <td>{product}</td>
            <td>{price}</td>
        </tr>
    </table>
{/exp:low_variables:pair}

Date and Date with Timezone fields

Simple Grid contains a Date and Date with Timezone field. When using a Date field, the template variable is the name of the column as indicated above, e.g. {my_date_column}

However, when using the Date with Timezone field there are modifiers, e.g. {my_date_column:date} and {my_date_column:timezone}. You essentially get two template variables out of this single column.

File fields

Using a File field in a SImple Grid is the same as using a standalone File field.

<!-- As a tag pair -->
{simple_grid_field}
    {product}
    {price}
    {simple_grid_field:photo}
        <img src="{url}" />
        <!-- {path} and {file_name} variables also work here -->
    {/simple_grid_field:photo}
{/simple_grid_field}

<!-- As a single variable -->
{simple_grid_field}
    {product}
    {price}
    {photo}
    <!-- modifiers are also available: {photo:url} {photo:file_name} -->
{/simple_grid_field}

Last updated 7 months ago

Was this helpful?