I have a field(let's call it foo
) with the Grid Fieldtype.
I have conditional to check if foo
is greater than 0 or not
Now here is the problem. It seems to me that when I only have 1 row in foo
, {foo:total_rows}
returns nothing.
I tried adding another row. This time {foo:total_rows}
returns 2. It is the same thing with 3, 4, etc. Basically anything greater than 1.
This shouldn't be the case. If there is only 1 row, it should return 1.
I would to point out that the foo
field is in a Channel with multiple Grid fieldtypes. It also has a relationship fieldtype for one of its columns.
I have another Grid field in that channel but without a realationship fieldtype for one of its columns. It is working correctly.
Any idea why this is happening?
UPDATE:
Tried out this code
<h3>field_total_rows {foo:field_total_rows}</h3>
<h3>total_rows {foo:total_rows}</h3>
{foo}
<h3>loop field_total_rows {foo:field_total_rows}</h3>
<h3>loop total_rows {foo:total_rows}</h3>
{/foo}
Output when the field contains only 1 row
field_total_rows
total_rows
loop field_total_rows 1
loop total_rows 1
Output when the field contains 2 rows
field_total_rows
total_rows 2
loop field_total_rows 2
loop total_rows 2
loop field_total_rows 2
loop total_rows 2
- Does this mean that the
total_rows
andfield_total_rows
can only be accessed inside the loop? - Why does the total rows variable only appear if it is greater than 1?
field_total_rows
is not available in the shortcut syntax (see docs) - which makes sense, because it only exists to ignore any parameters you've set on the tag pair.