Active
Project:
Fixed Block Content
Version:
8.x-1.1
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
3 Nov 2020 at 14:39 UTC
Updated:
4 Feb 2022 at 10:52 UTC
Jump to comment: Most recent
Comments
Comment #2
bessonweb commentedComment #3
serverjohn commented+1 on this. Would love to see how/if this is possible.
Comment #4
serverjohn commentedI figured out a way to get this to work with the UUID of the block that fixed block renders. To find the UUID export the single configuration of the fixed block (/admin/config/development/configuration/single/export). Don't use the fixed block UUID. As long as the fixed block has generated the block the following should work.
{{ drupal_block('block_content:009b4219-5fbe-49bf-9da5-c84f875fdb2a') }}Comment #5
bessonweb commentedThanks @serverjohn I will test this !
Comment #6
serverjohn commented@Bessonweb You are welcome! However, after some testing I have found a hole in this solution. If the block is recreated, even though the config stays the same, it seems the UUID changes. So for in my real world test I imported a single fixed block into the configuration. Then I used the UUID in the configuration in my template. The block was not rendered. So all things considered I don't know that this it is possible to link to the fixed block. Only the block that is created by the fixed block can be referenced. I have just decided to manually change the twig templates when the blocks are recreated. e.g. (
{{ drupal_entity('block_content', 6) }})Comment #7
salvor_hardin commentedHello, I found a way of printing a fixed block without using the UUID of the content block, that is a not a practical and consistent way of doing.
In a preprocess, use this :
Then just print {{ block_name }} in your template !
Comment #8
franknoel commented@Salvor_Hardin Your solution is great, but it only renders the block content. If you also want to have the block template, you can provide it with the render array's `#theme` key. For exemple:
Comment #9
mark_gerarts commentedSince you're using the Twig Tweak module, you can do this as well:
{{ drupal_block('fixed_block_content:your_fixed_block_machine_name') }}