2

I'd like to be able to reference my programmed block as a field in a paragraphs.

I've

  • Generated a module with drupal console - drupal generate:module
  • Used the template for a block from the example module. Only has Plugin/Block/MyBlock.php

I create a new field in my paragraph

  • Field type Reference
  • choose other

How do I get the block to be able to be embedded in this way?

1 Answer 1

4

To achieve this you may use the Block field:
From module description:

Use Cases
Add blocks to a node's sidebar.
Add blocks to paragraph.
Create a carousel of content and configurable blocks.

  1. install and enable the module
  2. Create a new field of type Block(plugin) in your paragraph type
  3. In case you want only your custom block to be referenced in the field settings uncheck all other blocks in the AVAILABLE BLOCKS config like this for my Hello block for exemple enter image description here
  4. now you can reference your block in the paragraph.
1
  • This is what I ended up doing. My block is now appearing in the block reference list but this is easier.
    – Interlated
    Commented Feb 19, 2021 at 0:09

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.