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

How to tell is a grid field is being used inside a relationship tag?

How Do I?

User z9NVFGOr's avatar
User z9NVFGOr
3 posts
6 days ago
User z9NVFGOr's avatar User z9NVFGOr

This is probably a very easy one (it’s 6.30 on friday so I’m running on empty), but is there a consistent way to test if a grid field is being used inside a relationship tag - somethnig simple (in my case, if video show it if else image)

IE:

{relationship_field}
 {if relationship_field:grid_field_has_content}<!-- << what works here??? -->
  <!-- video code here -->
 {if:else}
  {relationship_field:image_file_field}
 {/if}
{/relationship_field}
       
User z9NVFGOr's avatar
User z9NVFGOr
3 posts
6 days ago
User z9NVFGOr's avatar User z9NVFGOr

I know it’s filthy but I have this working with an embed for now.

{relationship_field} {embed='inc/the_grid_stuff' embed_entry_id="{relationship_field:entry_id}"} {/relationship_field}

but I’m sure there’s a more performant way…?

       
User olbp8DKG's avatar
User olbp8DKG
9 posts
6 days ago
User olbp8DKG's avatar User olbp8DKG

I have noticed a difference sometimes between {if my_grid} and {if mygrid != ""} - can’t say why this works/doesn’t work.

I have done similar to your solution using an embed, it works. On one site I had a relationship field referencing 5 entries in 7 different channels, and each entry had it’s own (complex) display requirements, an embed for each channel got it working and the overhead was minimal..

       
User z9NVFGOr's avatar
User z9NVFGOr
3 posts
5 days ago
User z9NVFGOr's avatar User z9NVFGOr

Thanks, I’ll try the latter, see if it works…

       

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.