By jrugel on
Hi... I need a help with Drupal 8 templates, please.
I created a custom block, I can create a theme for the custom block (the instance), but I can't create a theme for the Custom Block TYPE (let's call it "the prototype").
I meant, is there a way to theming the different Custom Block Types?
And a "bonus question": Why in the Theme Debug I can see "block--block-content.html.twig" twice? Should I see one "block--block-content.html.twig" and one "block--CUSTOM-BLOCK-TYPE-content.html.twig"
I'm running Drupal 8.1 stable.
Comments
\,,/
By default there is no way to theme custom content block bundles (type), however for Adaptivetheme I developed a way that you can, and you can implement this in your theme.
This would give you the block template:
block--bundle--the-prototype.html.twigI can't answer the bonus question, suppose it's a bug. Notice I use array_splice() to slot the template suggestion in the array rather than pushing it on the end and overriding the template for the instance.
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
It worked.
It worked for me. Thanks a lot.
This works for me as well.
This works for me as well. nice work!
following ...
Following for notes purposes.
spritefully yours
Technical assistance provided to the Drupal community on my own time ...
Thank yous appreciated ...
Nice!! Worked for me, thanks!
Nice!! Worked for me, thanks!
Thanks a lot!
Worked for me too. Whyever this isn't already in core o.O
Try this - https://www.drupal
Try this - https://www.drupal.org/project/block_type_templates
duplicate
.
any comments on the differences?
- test on BlockContentInterface
- adding suggestion at the end instead of inserting
Thank you very much! It
Thank you very much! It worked for me great!
Woah
I have no idea how this works but it does :D
Can you explain to a newbie?
Thanks :)
This worked for me, thank you
This worked for me, thank you!
Worked for me
Worked great, thank you.
Worked for me as well.
Worked for me as well.
Thank you so much :)
component libraries
Isn't this possible with https://www.drupal.org/project/components ? I recently learned about this module on the Business Pinterest showcase.
Worked perfectly
It worked perfectly, thank you.
Can't Get it To Work D8.6
Hi everyone,
I created a mytheme.theme file in my custom theme's root folder. I pasted this function in, replaced MYTHEME with my theme name.
The problem is, the function is output as plain text at the top of my site...
Anybody have an idea why it's doing that?
THEMENAME.theme files need to
THEMENAME.theme files need to start with
This works for me.
This works for me.
Any ideas on how to also add the view mode to the suggestions?
Building websites for a better world
Template suggestions for custom block view modes
Template suggestions for custom block view modes
Why I can see "block--block-content.html.twig" twice?
It's a bug.
Remove duplicate suggestions block--block-content.html.twig
This really should be in core
This really should be in core. I'm moving back towards Blocks and Block Types and away from Paragraphs and Paragraph Types now that we have Layout Builder but ran into this issue. Paragraph Types have template suggestions by default but you have to go out of your way to figure out how get template suggestions based on Block Type. The fact this isn't in core encourages people to work in a non-component based way, which I think is the opposite direction we should be pushing people.
Elegant Way to Theme block type
Though Jeff Burnz Suggestion work. You can easily theme your custom block with Display suite.
With Display suite installed, you can select the layout type in the manage fields section of your custom block. When you select the layout type, you'll be given template naming suggestions and where the original template resides.
Copy and paste in your sub-theme And Edit the theme to your heart's content. :)
Workaround no longer needed
As of D8.8, You can use a template name of `block--inline-block--<custom-block-name>.html.twig` with no extra code to add it into the suggestions. This is using Layout Builder to place the custom blocks.
The workaround is still needed
The custom block name was always included within the template suggestions. The block bundle (custom block type) still isn't.
A custom block type of "My Fancy Block" would have the template suggestion
block--bundle--my-fancy-block.html.twigwith this hook.