Account created on 27 October 2007, about 17 years ago
#

Recent comments

🇦🇺Australia drasgardian

For anyone else trying to get field groups to show up on a custom entity display, I found the following. Working within field_layout regions too.

1. Add to theme registry.
```
/**
* Implements hook_theme().
*/
function MY_MODULE_theme($existing, $type, $theme, $path) {
return [
'MY_ENTITY' => [
'render element' => 'elements',
],
];
}
```

2. Prepare the entity template variables beneath the 'content' key.
```
function template_preprocess_MY_ENTITY(&$variables) {
$variables['view_mode'] = $variables['elements']['#view_mode'];

// Helpful $content variable for templates.
$variables += ['content' => []];
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}

}

```

3. Add MY-ENTITY.html.twig file to templates
With at least:
```
{{ content }}
```

🇦🇺Australia drasgardian

A drawback of the above seems to be that a hyperlinked image continues to be hyperlinked even when rendered inside the wysiwyg editor. A user wouldn't expect that clicking on an element inside the editor would result in linking away from the page.

The new logic within template_preprocess_entity_embed_container perhaps shouldn't fire when embedding inside the wysiwyg.

Patched attached, but possibly there is a better way rather than checking the route.

🇦🇺Australia drasgardian

Sorry, jumped the gun a bit on that one. This patch should be better

🇦🇺Australia drasgardian

Re-rolled the patch so other attributes can also have multiple values.

🇦🇺Australia drasgardian

Why was this marked as fixed without being merged?

Production build 0.71.5 2024