Seems odd that this isn't working for me, but I'm not able to get the value of a custom field of the parent when within a child paired tag.
Example:
{exp:channel:entries}
{if bg_color}
{bg_color limit="1"}
img class="{child_custom_field}" src="{parent_custom_field}"
{/bg_color}
{/if}
{/exp:channel:entries}
Basically I'm giving a product multiple color options, but when showing a single one I want to give the parent's image a class based on a single child. I tried using {parent:custom_field} but that doesn't work.
In my original code, I have a few more "if's" throughout; this is a simplified example. I can supply the full code if that will help.
-
Hi Steve,
That’s happening because the context within {bg_color}...{/bg_color} is the child, not the parent.
The only way to do this is to use an embed, and pass the parent's field value to it:
{exp:channel:entries}
{if bg_color}
{embed="includes/_bg_color" parent="{entry_id}" parent_custom_field="{custom_field}"}
{/if}
{/exp:channel:entries}
includes/_bg_color template:
{exp:playa:children entry_id="{embed:parent}" field="bg_color"}
<img class="{child_custom_field}" src="{embed:parent_custom_field}" />
{/exp:playa:parents}
Hope that makes sense. -
-
-
Loading Profile...


Twitter,
Facebook, or email.

EMPLOYEE
