2

I have created a custom module providing a block.

The block is available in the block library under "Block Layout" (/admin/structure/block).

On the other hand, I have a custom content type with an "Entity reference revisions" field that allows me to add any kind of content to a page. I can select "Add Drupal Block" in this field but my custom block either:

  1. Shows up in the list if it's placed in the block layout (but then it appears twice on the page)
  2. Doesn't show at all in the list if it's not placed in the block layout

Am I misunderstanding something or doing something wrong ? Thanks!

1
  • 1
    I'm not sure if you can use Entity Reference Revisions to place blocks (hopefully someone else can chime in about that). What you can do using the core modules is to enable Layout Builder and place the block using Layout Builder. Layout Builder will let you build a specific layout for your custom content type, or even a specific node of that content type. Commented Jan 21, 2022 at 9:56

1 Answer 1

2

You've created a custom block plugin in a custom module and now you need to configure it? Then the question is where to store the configuration when you don't want to use the block layout.

This could be the Layout Builder as commented or a smaller, more targeted module like https://www.drupal.org/project/block_field.

The "Entity reference revisions" field is usually used together with Paragraphs. Then "Add Drupal Block" adds a paragraph type, in which you could use the mentioned field module. This module can be used as a stand-alone node field as well if the only purpose of this field is to place the block.

1
  • Thank you very much, that works like a charm!
    – Robin
    Commented Jan 21, 2022 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.