We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Still not possible to check if Grid field is empty?

How Do I?

Giraffentoast's avatar
Giraffentoast
152 posts
10 years ago
Giraffentoast's avatar Giraffentoast

Am I missing something or is it still not possible to check a Grid field for empty / not empty (or number of rows) without actually looping through it?

This is a huge problem if you need to do something like this:

{if field1 OR field2 OR field3}
...
{/if}
       
Jos Medinger's avatar
Jos Medinger
16 posts
10 years ago
Jos Medinger's avatar Jos Medinger

I’ve checked for grid entries like this

{grid_field row_id="1"}
  {if "{grid_field:grid_field_1_name}" != ""}
  show grid content with usual grid code
  {/if}
{/grid_field}

not ideal but at least it lets you check for content in the first row

       
Giraffentoast's avatar
Giraffentoast
152 posts
10 years ago
Giraffentoast's avatar Giraffentoast

How would you do my example above? Field1, field2, field3 all being separate grid fields.

       
Jos Medinger's avatar
Jos Medinger
16 posts
10 years ago
Jos Medinger's avatar Jos Medinger

If you’re testing for empty then if row 1 is empty then by default, all other rows are empty… so you only need to query the first row… Just substitute ‘grid_field’ in the example for your grid’s name and ‘grid_field_1_name’ for the name of your first column that you’re testing against

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.