I’m looking to pull in a specific grid row from a related entry, whereby the row is specified by a field on the parent entry:
Parent entry
Relationship
Custom_Field
Child entry
grid_field
Row 1
Row 2
Row 3I’ve been trying to make this work with row_id without success.
{exp:channel:entries channel="channel_name"}
{preload_replace:set_row_id="
{if Custom_Field == "One"}1
{if:else Custom_Field == "Two"}2
{/if}
"}
{relationship:grid_field row_id="{set_row_id}"}
{relationship:grid_field:field}
{/relationship:grid_field}
{/exp:channel:entries}I think it is because it is not possible to pull in dynamic parameters because of the parse order.
I have tried using basic PHP and embed without any luck.
How else could I achieve this goal?
v:2.11.2
I’m not sure that preload_replace will work inside an entries tag.
Have you tried hard coding the row ID to see if that works:
{exp:channel:entries channel="channel_name"}
{relationship:grid_field row_id="1"}
{relationship:grid_field:field}
{/relationship:grid_field}
{/exp:channel:entries}Hi Rob,
Thank you for your reply. Hardcoding the row_id is fine and pulls in the right data. My goal was to make this dynamic so the row_id is set by a field on an entry.
Though not ideal, I have found a workaround which use {segment_id} which does render within the channel tag parameters as it gets parses sooner.
Yep segment ID will work, you could also use real numbers instead of One, Two etc. in your custom field
Custom text field, ie my_number_field, and populate with a real number like, 1,2,3 etc then call the field value into the relationship tag:
{exp:channel:entries channel="channel_name"}
{relationship:grid_field row_id="{my_number_field}"}
{relationship:grid_field:field}
{/relationship:grid_field}
{/exp:channel:entries}That should work, if all else fails you could put the relationships tag into an embed and pass the number through that way.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.