Skip to content

Instantly share code, notes, and snippets.

@backlineint
Last active March 29, 2017 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save backlineint/9687354d0ba6a09ac645e8dbe87add2d to your computer and use it in GitHub Desktop.
Save backlineint/9687354d0ba6a09ac645e8dbe87add2d to your computer and use it in GitHub Desktop.
More Involved Use of field_target_entity
{# Force caching for entities we’re not rendering #}
{% set catch_cache = content.field_season|render %}
{% set season = content.field_season|field_target_entity %}
{# Can now access fields on the referenced practice entity like… #}
{% include "@molecules/card/card.twig"
with {
"img_src": file_url(content.field_image|field_target_entity.uri.value),
"img_alt": content.field_image|field_raw('alt'),
"header": label|field_value,
"season": season.name.value,
"city": season.field_city.value,
"copy": content.body|field_value
}
%}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment