Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Some modules like facets use the block id for functionality.
By overwriting the block id facets no longer works. This should be default by the next release.
Comment | File | Size | Author |
---|---|---|---|
#11 | missing_block_id-3114611-11.patch | 435 bytes | elaman |
#7 | 3114611-block-ids.patch | 791 bytes | marcoka |
Comments
Comment #2
tim_djComment #3
awasson CreditAttribution: awasson commentedJust ran into this today. The fix for me was to copy the block.html.twig template from the parent Radix theme into the templates/block directory in my subtheme and edit the twig to include the ID.
Code before somewhere around line 14 in block.html.twig:
<div{{ attributes.addClass(classes)|without('id') }}>
Code after:
<div{{ attributes.addClass(classes) }}>
Clear caches and the browser cache and it works now.
I would think a long term solution would be to include a conditional in the Theme Settings Page to turn ID's off and on.
Cheers,
Andrew
EDIT: I just noticed that the 8.x-4.x version of radix writes the twig via the following code which is going to throw a wrench in things. Maybe there's a twig filter that will print ID's... I don't know.
If you really need a workaround, I'd just grab the block.html.twig file from core/themes/classy/templates and put it in the templates/blocks directory of your subtheme. It's not the perfect solution but it will do in a pinch.
What the heck. A better workaround is to just use the block template from the 8.x-3.x version and don't strip the ID's.
Comment #4
marcoka CreditAttribution: marcoka commentedI have a probleme here too. So i checked out the component that is beeing included in the normal block template
It looks like this.
So ids should be there i guess. I debugged and for the title block the id is "pd5-radix-page-title", pd5-radix beeing my themes name. For example.
If i flush the cache i can see that no views blick has an "id" index in $context, so no "id" is never used, printed.
Comment #5
marcoka CreditAttribution: marcoka commentedI hacked the block.twig in components now just renaming the 'block' class. Doesnt change anyothing, that class is never added. I dont get the logic here at all.
Comment #6
marcoka CreditAttribution: marcoka commentedOk lets check the preprocess of radix includes/block.inc
If $variables has no "id" index an id is never set. So most blocks have none. They have a "plugin_id" so i added an esle if to use that plugin_id if "id" is not avaliable. That works. I laso think plugin_id should be unique.
Comment #7
marcoka CreditAttribution: marcoka commentedComment #8
marcoka CreditAttribution: marcoka commentedOk that puts the id into the class area. I suggest adding an "id" tag instead. Modification of the components blocks/block.twig is neccessary.
My suggestion would be this:
I added a cleaned_id variable and added the id using attributes {{ attributes.setAttribute('id', clean_id) }}
This finally will give each block a unique id. Very important in my opinion for anchors and other target stuff.
Comment #9
elamanI'm using Facets and this is an actual issue. Maybe this needs work?
Comment #10
elamanI've modified the block.twig component to not remove the id attribute.
Comment #11
elamanPrevious patch is invalid. Here is the valid one.
Comment #12
devkinetic CreditAttribution: devkinetic at CommonPlaces Interactive commentedUPDATE, nothing seems to be working and further research has led me to https://www.drupal.org/project/drupal/issues/1880646 where we can see the effort in drupal core to replace block id's with plugin ids. I ended up just using a template override due to time contsraints but this is clearly an pretty major issue for radix.
Comment #13
devkinetic CreditAttribution: devkinetic at CommonPlaces Interactive commentedComment #14
marcoka CreditAttribution: marcoka commentedWorking on a D9 setup. This ist totally screwed up here because there is rellay no useful "bundle" name. Sometimes it is basic.
I need a way to create a unique id here. Will report back if i find something.
Yes in D9 use plugin_id instead of id
This works for me here.
Comment #15
elgandoz CreditAttribution: elgandoz as a volunteer commentedThe above example is almost right but there's a typo. It should be:
plugin_id ? 'block--' ~ plugin_id|replace({"_": "-", ":": "--"})|clean_class,
This should really be fixed in the main theme since all the layout builder blocks do not print any class.
Comment #16
devkinetic CreditAttribution: devkinetic commented