Score:0

Add a new contextual link to custom block type to edit layout

za flag

I have a custom block type using Layout Builder.

How do I add an Edit Layout item in the contextual link menu?

The link should go to /block/{nid}/layout; after saving, the layout returns to where you started.

Score:1
de flag

You do this by implementing *.links.contextual.yml in a module. For example, to add a contextual link on Nodes to node layout builder, you would implement the following: [MODULE].links.contextual.yml

node_layout:
  title: 'Edit Layout'
  route_name: 'layout_builder.overrides.node.view'
  group: 'node'

You can find out the route_name for various entities by enabling the Devel module, and going to /devel/routes.

Sarah C avatar
za flag
Thank you. Where would I place this file? And is there any other code to write?
Jaypan avatar
de flag
It goes in a custom module. This solution requires an understanding of how to create custom modules in Drupal.
Sarah C avatar
za flag
I have a custom module working. I've tried placing the file in the module's main folder and then config folder, to no success.
Jaypan avatar
de flag
In the module root, and clear the cache. Also make sure the module is enabled
Sarah C avatar
za flag
Ah, that's the ticket. Thank you!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.