Defining contextual links
Contextual links are a bit more complicated than the other types of links we've seen before, but nothing is too challenging for us. Let's take a look at how we can add contextual links to our salutation component so that users can navigate to the configuration form via a contextual link.
First, we will need to create the *.links.contextual.yml
file and define the link:
hello_world.override: title: 'Override' route_name: hello_world.greeting_form group: hello_world
Nothing too complicated here. Again, we have a title
link and a route_name
. Additionally, we have a group
key, which indicates the group name that this link will be a part of. We will reference this later.
Next, we will need to alter our theme hook template file because the contextual links are printed in a title_suffix
variable that is available in all theme hooks and is used by various modules to add miscellaneous data to templates...