Problem/Motivation

The default template and preprocessing function causes the title of an RDF entity to malrender. The template (rdf-entity.html.twig) contains the following section to render the label:

<article{{ attributes }}>
  {# ... #}
    <h2{{ title_attributes }}>
      <a href="{{ url }}" rel="bookmark">{{ label }}</a>
    </h2>
  {# ... #}
</article>

So we should expect the label to be rendered as follows:

<article role="article">
  <h2>
    <a href="/rdf-entity/my-entity" rel="bookmark">My label</a>
  </h2>
  <!-- ... -->
</article>

But instead, we get something like this which includes a whole bunch of unwanted field markup:

<article role="article" class="contextual-region">
  <h2>
    <a href="/rdf-entity/my-entity" rel="bookmark">
    </a>
    <div>
      <a href="/rdf-entity/my-entity" rel="bookmark">
      </a>
      <a href="/rdf-entity/my-entity" hreflang="en">My label</a>
    </div>
  </h2>
</article>

Steps to reproduce

Show an article as secondary content on a page, e.g. in a view.

Proposed resolution

In template_preprocess_rdf_entity(), output the label as a string and not as a rendered field.

Remaining tasks

User interface changes

The HTML output for the base template will render correct HTML for the label.

API changes

None.

Data model changes

None.

Workarounds

This workaround can be put in the theme file as a quick fix for the issue:

function mytheme_preprocess_rdf_entity(&$variables) {
  $variables['label'] = $variables['rdf_entity']->label();
}

Comments

pfrenssen created an issue. See original summary.

pfrenssen’s picture

Issue summary: View changes