Last updated October 21, 2015. Created on December 20, 2012.
Edited by batigolix, acabouet, hwi2. Log in to edit this page.

I sometimes do not like having to click on the Content link and then have to search for that page in the Content/Nodes screen, so this little code is handy for quickly editing a page while bypassing the Content list. Wordpress also has a quick command for this, but I never found it on Drupal.

global $user;
$role = $user->role ;
                                if($role=="admin" || $role=="administrator")
                                // Generate all your Drupal and PHP variables
                                    $nid = arg(1);
                                    $edit_this_page_link = ("<a style=" color:cyan;" href="' . $base_url . '/node/' . $nid . '/edit">Edit This Page</a>");

This can go into any page.tpl.php or even a preprocess function in your template's template.php file.

Looking for support? Visit the forums, or join #drupal-support in IRC.


headalien’s picture

global $user;
$roles_array = array_values($user->roles);
if( in_array('admin', $roles_array) ||  in_array('administrator', $roles_array) ){
	$nid = arg(1);
	$edit_this_page_link = '<a style="color:#F00;margin-left:100px;" href="' . '/node/' . $nid . '/edit">Edit This Page</a>';
	echo "<div>$edit_this_page_link<br /><br /></div>";