I have an entity reference field set in Manage Display to 'Rendered Entity' and am working with the field's template to conditionally show the link based on the referenced node's published status. I'm using 'Rendered Entity' so I have access to isPublished()
.
How can I get just the path of the referenced node in the field's template?
Within {% for item in items %}
, this works great to get the referenced node's title: {{ item.content['#node'].title.value }}
, but I can't find what I need for the url.
web/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php
for the implementation of this field formatter. Should you want to customize the output, I suggest you extend this formatter and override theviewElements()
method.