When I hover over a block on the front end, I get the Contextual Links popup to edit the block. Can I also set this so when someone with permissions to do so hovers over a node, they get a link popup to edit that story?


To set permissions for different user roles to access the contextual links: Navigate to the Permissions page (People > Permissions tab). For each role you can enable or disable the Use contextual links permission.


To avoid hacking core, this code put in a custom module accomplishes the exact same thing as the solution by Psykoral/Clive:

//Implements hook_node_view_alter()
function mymodule_node_view_alter(&$build) {
  if(isset($build['#node'])) {
    $node = $build['#node'];
    if(!empty($node->nid)) {
      $build['#contextual_links']['node'] = array('node', array($node->nid));

There is a sandbox project for this on Drupal.org. The only caveats I found were when a theme overrides theme_preprocess_region() and removes markup that is needed, or it overrides theme_menu_local_tasks() and it changes markup in certain ways then I didn't get the contextual links.

The only other problem I found was if my node had no content in the body, then there is nothing to hover over in order to get the contextual links. I just made sure something is always in the node content to avoid this problem, even if it is only a  . I did this through a DS field that is added when the node body is empty, but there could be a number of ways to deal with this issue.


Because I went looking around for this FOREVER, hopefully it'll help someone still digging up this thread. I searched for 3 days, found all kinds of 200 lines of code nonsense, custom modules that claimed to do this, yada yada, all to no avail.

Basically what I found was that the PHP that builds contextual links specifically looks for it NOT to be it's own page node, or in full view mode. Well jeebs, thanks, that's exactly where I wanted contextual links! How awesome of you to hard code it and decide not to give me them on pages I want to be able to edit without going into the Admin interface.

Anyway, bitterness aside (can you tell I've been looking for this answer for a while?)... it's time to brute force remove that so we can enable it for all full page nodes in one shot.

  • Edit /modules/node/node.module
  • About line 1303 you should see this line:

    if (!empty($node->nid) && !($view_mode == 'full' && node_is_page($node)))

  • Comment it out and make it this instead:

    if (!empty($node->nid))

  • Save, upload, and dance!

Basically, what this does is make contextual links available to every block, view, or node, when previously the code was specifically blocking them from 'full view mode' and if the node is being viewed as an entire page.

May not be the most 'official' way to do it via the Drupal UI, but it does what I want it to do anyway. Hope it helps someone. Going to glue my hair back to my head now.

  • Please do not ask people to hack core files. No matter how easy to do it, lets get it fixed for all users.
    – AKS
    Nov 3 '12 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.