Add Edit this node/block link to Drupal View

It is often useful to add a "edit this node" or "edit this block" if a site editor is viewing content on a page that is not the node page itself. This includings viewing content from a "view" page where the normal edit tabs are not present for nodes or blocks.

Add the snippet to the template page for the content type. ie node-TYPE.tpl.php

TYPE with the machine readable name of the content type.
TODO: ADD RELEVANT CONTENT TYPE with machine readable name of the content type.

  1. if (user_access('edit any TODO: ADD RELEVANT CONTENT TYPE'))
  2. {
  3. print l('Edit this', 'node/'.$node->nid.'/edit');
  4. }

If you liked this, you'll love my book, Master Drupal Module Development.

"..the must have drupal developers book"

Feeling stuck with Drupal 8 module dev?

Get the free 7 lesson course that will help you get started today without feeling overwhelmed.

  • Create Drupal modules with just a few commands using the Drupal Console
  • Create custom pages
  • Create custom blocks
  • Create admin forms
  • Demystify routers and controllers
  • Bonus material

Find out more


Nice one, very handy!

thanks, just wht I was looking for.

if (node_access('update', $nid , $user))
{ echo " ";
echo l('Edit', 'node/'.$nid.'/edit');
echo "";

Thanks for the great information provided..........

Add new comment