You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/channels/entries.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1286,8 +1286,8 @@ For instance, if you have a Relationship field with an `{if no_results}` block,
1286
1286
{/exp:channel:entries}
1287
1287
```
1288
1288
1289
-
NOTE: **Note:** Grid, File Grid, and Member fields do not have a `{if no_results}` conditional. Use [:total_rows](/fieldtypes/grid.md#total_rows-1).
1290
-
Fluid fields do not have a `{if no_results}` conditional. Use [:total_fields](/fieldtypes/fluid.md#total_fields)
1289
+
NOTE: **Note:**To test whether a Grid or File Grid field is empty, use [:total_rows](fieldtypes/grid.md#total_rows-1). For a Members field, use [:total_rows](fieldtypes/member.md#total_rows). For a Fluid field, use [:total_fields](fieldtypes/fluid.md#total_fields).
1290
+
1291
1291
```
1292
1292
{exp:channel:entries channel="blog"}
1293
1293
{if my_grid_field:total_rows == 0} Grid is empty {/if}
@@ -1296,7 +1296,9 @@ Fluid fields do not have a `{if no_results}` conditional. Use [:total_fields](/f
1296
1296
{/my_grid_field}
1297
1297
{if my_fluid_field:total_fields == 0} Fluid field is empty {/if}
Copy file name to clipboardExpand all lines: docs/fieldtypes/grid.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,7 @@ Make a copy of the field by clicking the "copy" icon -- two superimposed squares
68
68
69
69
Just as with other field types, you can specify whether a grid field is required or not. This applies to every row in the grid.
70
70
71
-
For some fieldtypes, you can choose whether its content should be included in search. The overall grid field must also be set to Include in Search, or else this setting will not have any effect. If you change the search inclusion status of an existing grid Field -- or make other changes to the field settings -- you will need to [re-index your content](control-panel/utilities/data-operations.md#search-reindex)
71
+
For some fieldtypes, you can choose whether its content should be included in search. The overall grid field must also be set to Include in Search, or else this setting will not have any effect. If you change the search inclusion status of an existing grid field or column, you will need to [re-index your content](control-panel/utilities/data-operations.md#search-reindex).
72
72
73
73
You may set a minimum width for each grid field. When the grid is set to display horizontally, any grid field with a minimum width will have that width applied to it; fields without any minimum width will be given the remaining space.
74
74
@@ -78,7 +78,7 @@ You may set a minimum width for each grid field. When the grid is set to display
78
78
Contents of a Grid Field are accessed via prefixed variables representing each column, surrounded by a variable pair. For example, if you have a grid field called `awards` with `name`, `details`, and `year_awarded` fields, your template code may look like this:
79
79
80
80
{awards}
81
-
<h3>{awards:name} - {awards:year_awarded}<h3>
81
+
<h3>{awards:name} - {awards:year_awarded}</h3>
82
82
{awards:details}
83
83
{/awards}
84
84
@@ -270,10 +270,12 @@ Outputs the data in the grid field as a table. All parameters available to the p
270
270
271
271
{grid_field:total_rows search:height=">55"}
272
272
273
-
When outside of a grid field tag pair, this modifier can be used to get the total number of rows in a field given a specific criteria. Useful for determining if there are any grid rows at all: `{if grid_field:total_rows == 0} Grid is empty {/if}`. Note that `no_results` is not a valid conditional for the Grid field. Also note that you need to wrap the tag in quotes and curly braces if you are using any parameters:
273
+
When outside of a grid field tag pair, this modifier can be used to get the total number of rows in a field given a specific criteria. Useful for determining if there are any grid rows at all: `{if grid_field:total_rows == 0} Grid is empty {/if}`. When using parameters, wrap the tag in curly braces. Quotes around the numeric result are optional:
274
274
275
275
{if "{grid_field:total_rows search:height='>55'}" == 0} No rows with tall things {/if}
276
276
277
+
NOTE: **Note:** Grid can process `{if no_results}` when existing rows are excluded by parameters such as `offset`, but a field with no stored rows returns without processing it. Use `:total_rows` to check whether the field has any rows. When nested in `{exp:channel:entries}`, put the Channel Entries `{if no_results}` block before the Grid tag pair.
0 commit comments