TransWikia.com

Contextual links for node blocks

Drupal Answers Asked on November 28, 2021

I have the Nodeblock and the Contextual links modules installed. They work fine, but I want to add the “Edit node” link in the contextual links for node blocks. For views, there is a “Edit view” link, but not for nodes. Is there a way to do that, maybe with a preprocess block function?

3 Answers

Try the Custom Contextual Links module. Here is an excerpt about it from the module's project page:

The Custom Contextual Links module allows you to add your own links to the contextual drop down widgets of blocks and nodes.

Contextual links are really great for quick access to settings pages within your Drupal install. They cut down the time required to click through the sometimes cumbersome Drupal administrative navigation. However, the links displayed in the contextual widget need to be defined through a module. This is where CCL comes in. This module allows you to add and manage custom links through a UI that will be displayed in the contextual widgets.

Answered by ARUN on November 28, 2021

You could add contextual link with a little piece of code very easily.

You have to use block_contextual_links_view_alter hook to add a link to a block.

function my_module_block_contextual_links_view_alter(&$element, &$items) {


            $element['#links']['edit_f_block'] = array(
            'title' => 'Change Content',
            'href' => url('admin/config/front/block', array('absolute' => TRUE)),
            );

}

This adds to all blocks, you should probably check which block it is and also if element is a block. See this post for a detailed understanding.

Answered by esafwan on November 28, 2021

Ok, it looks like you have to hover the actual body of the block to see those links. It doesn't display them if you hover just the title.

Answered by Marius Ilie on November 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP