Be sure to checkout our newest add-on, Speedy — Advanced Caching for ExpressionEngine.

Compatibility updates:

  • Publisher is EE5 compatible, but it does not currently support the Fluid field (it's in the works).

Ticket: {total_rows} always renders as 1 for a simple_grid field inside a regular Grid field

Status Resolved
Add-on / Version Simple Grids & Tables 1.0.2
Severity
EE Version 4.3.4

Jennifer Martin

Sep 24, 2018

Description: {total_rows} seems to always render just as “1” when used inside a simple_grid tag pair where the simple_grid field is used inside a regular Grid field.

Try this code:

{grid_field}
{grid_field:simple_grid_field}
{count} of {total_rows}—{simple_grid_data_col_a} {simple_grid_data_col_b}
{/grid_field:simple_grid_field}
{/grid_field}

Let me know if I need to setup server access, but I think you’ll be able to replicate.

#1

BoldMinded (Brian)

Sep 24, 2018

Did you try adding a prefix? e.g.

{grid_field:simple_grid_field prefix="foo:"} {foo:total_rows} {/grid_field:simple_grid_field}
#2

BoldMinded (Brian)

Sep 26, 2018

I assume the value of total_rows is the value of how many Grid rows there are, not Simple Grid rows? Have you tried the prefix option yet?

#3

Jennifer Martin

Sep 28, 2018

Sorry for the delay - our company account email (design@) is different to mine and I don’t get an email with a notification of the replies despite adding myself to the ticket… so I tend to forget to check back.  But I did try it with a prefix and that still doesn’t work either:

{menu_items:pricing prefix=“foo:”}
{foo:count} of {foo:total_rows} - {foo:time}{if foo:cost} / ${foo:cost}{/if}
{/menu_items:pricing}

With the above {foo:total_rows} still always renders as 1, but {foo:count} does increment correctly.

#4

Jennifer Martin

Sep 28, 2018

Sorry I should also say that in my case, I have multiple Grid rows too, so {total_rows} does not appear to be rendering the number of Grid rows… but that must be where the conflict lies because total_rows is a valid variable inside a grid.

Thanks,
Justin

#5

BoldMinded (Brian)

Sep 28, 2018

Thanks for clarifying. New build in the next post should fix it. Here is the template code I used to test:

{exp:channel:entries entry_id="6"}
{grid}
    total_rows: {grid:total_rows}
    <table>
    {grid:simple_grid}
        <tr switch="{switch='odd|even'}">
            <td>{text}: {total_rows}</td>
        </tr>
    {/grid:simple_grid}
    </table>
{/grid}
{/exp:channel:entries}
#6

BoldMinded (Brian)

Sep 28, 2018

Comment has been marked private.

#7

Jennifer Martin

Sep 29, 2018

Thanks Brian - confirmed that fixes it!

Login to reply

Contact

For add-on support, please use the Support section. General inquries and pre-sale questions can be sent to support@boldminded.com.