Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293850

Ability to display block_content entities independently, also outside of Blocks

$
0
0

Problem/Motivation

When I display a custom block using the block layout configuration the block prints using the block.html.twig template. However if I have a custom block view, each row is just the rendered fields, not the whole rendered block. The same problem occurs displaying a rendered block content entity in an ER field or displaying it programmatically like a normal content entity. It causes problems for themers and is inconsistent with similar row formats like "Show: Content" for nodes, and also means that contextual links don't show.

The problem is that block_content entities explicitly have no defined #theme/template because they were expected to always be rendered as a block (core, page_manager, .. doesn't matter, but it has to be a block).

Steps to reproduce:

  1. Create a custom block
  2. Create a view showing custom blocks
  3. For the view format select Show = Custom block

Available workarounds

  • Twig Tweak v2 has a Twig tag that lets you render blocks including block content.
  • Block content template adds a new template for block content entities and restores contextual links.

Proposed resolution

So the answer to this might simply be that this is on purpose, if you want to display something with views or references or ..., then don't use block_content but either a node type or custom entity type. I'm not sure I see an alternative for keeping it working correctly and efficiently (=no double-render caching of the same content, for example) also within a block. However it's a major DrupalWTF moment when you realize this. It's also a while since D8 was released, there's no documentation about this and there's functionality available in core to trigger this bug.


Viewing all articles
Browse latest Browse all 293850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>