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

Add entityreference formatter option to "ignore access checks"

$
0
0

Problem/Motivation

Referenced block entities (not content blocks) do not show up when rendered UNLESS they are visible anyway in some region.
This is due to access and visibility check.

Proposed resolution

Add an entityreference formatter option "ignore access checks" that opens a sitebuilder the possibility to solve this.

Remaining tasks

Check if this is feasable.
Hack it.

User interface changes

Additional formatter option.

API changes

TBD

Data model changes

TBD

Original Report

When an entity reference field references a block, and the field formatter is set to render item, the block will only be visible if it is already placed in a region on the theme block administration page. It should be possible to view the block even if the block is not generally visible in a region.

Steps to reproduce:

  1. Create a entity type (node, taxonomy term, block etc.) with an entity reference field
  2. Set target entity type to block
  3. Set field formatter to rendered entity
  4. Create a custom block that is not visible in a theme region
  5. Reference the block from your content type
  6. The referenced block will not be visible

This can be useful in many cases. I need it to create blocks with tabbed content (blocks within a block).

The reason for the problem is that the block module checks for each block's status. If it is not active in the current theme, it will be marked with status = FALSE. Then in the access check of the block module the access to the block is not permitted and the block is not rendered.

It is pretty easy to make a fix for this by implementing hook_ENTITY_TYPE_load() and set status to TRUE. However, I think a better way is to change core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php to set the status to TRUE if the entity has the setStatus method enabled. But this approach does not work as the access to the block has already been checked and cached. So it would be necessary to invalidate the cache.

Can anybody see a nice solution to this?


Viewing all articles
Browse latest Browse all 295165

Trending Articles



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