Is it possible to improve the tokens support in Layout Builder? It seems that at present only the most basic of tokens will render. E.g.
- In a Taxonomy Term Layout, custom block, [current-date:long] works but [term:name] does not.
- In a Node Layout, custom block, [current-date:long] works but [node:title] does not.
I understand this is down to the context that token/token_filter has. If these tokens can work, that it will make (to me at least) a huge difference to how useful LB is. One of the most useful aspects of panels, by comparison, is around using the contextual tokens, both as content and as Views contextual filter values etc.
??
Comments
Comment #2
cilefen commentedComment #3
cyb_tachyon commented#2233353: Convert Token API into plugins and #3154986: Support context aware block plugin creation look to be blockers for making this happen.
Comment #6
brooke_heaton commentedIs there any progress on this? Not being able to add a token for [node:title] in Layout Builder has to be among the dumbest bugs in Drupal 8/9.
Comment #7
tim.plunkettThis is a weird middle ground between feature request and bug report.
A custom block placed via the Block UI would have no way to use entity-specific tokens, even if you placed it only on a node or term page
(if that DOES work, then this is 100% a bug and should be a straightforward fix)
But of course when you're using LB on a node or term page, you expect the ability to use those tokens.
Either way, like all issues, this is only going to get resolved if someone takes the time to work on it.
Comment #8
brooke_heaton commentedFWIW, our workaround is to make our own token. Nid contextual arguments in views work, so it's befuddling why a token for a node would not work in a custom block in LB:
The fact that the above is necessary seems just sad.
Comment #10
tonytheferg commented+1 for better token support in custom blocks.
A possible work around is also to build a block view with the relationships and all fields for all the tokens you want to utilize. Then instead of using the custom block from LB, use the custom text from views for the markup, and insert in the view into the Layout.
Comment #14
anybody+1 on this, just had the same need.
As it seems, contrib tries to solve this: https://www.drupal.org/project/entity_token_block
But for me it currently doesn't work well (#3468068: Provides "User" and "Product variation" entity token block types on taxonomy term layout builder) and seems a bit hacky?
So a general core solution would be much better.
Comment #15
anybodyComment #16
aram.gevorgyan commentedHi , before this will be fixed, I have created workaround module which is really simple and can help you, module is adding Ckeditor filter and checking current url is node or group and doing token replace, please try https://www.drupal.org/project/node_token_filter, if in some cases it will not work please give me some feedback and I will take a look, I hope this will resolve your issues.