Quick 'edit' link of the nodes

Just to give a 'quick edit' link to each and current node on pages with excerpt
edit link next to the '$links' read more' as alternative to the going to the actual node to get edit tab.. saves editors 2 links&load!
for Drupal 4.7.x and 5.x
on node.tpl.php replace

   <?php if ($links): ?>
      <div class="links"><?php print $links; ?></div>
    <?php endif; ?>

with

<?php if (user_access('administer nodes')): ?>
<a href="<?php print '?q=node/'.$node->nid ?>/edit" title="
  <?php print t('Edit') ?>">edit</a>
<?php endif; ?>

Not overwriting existing links, and using l() and $nid

Chill35 - June 16, 2008 - 23:10

<?php if ($links): ?>
  <div class="links"><?php print $links; ?></div>
<?php endif; ?>

<?php if (user_access('administer nodes')): ?>
  <div><?php print l('Edit', 'node/' . $nid . '/edit'); ?></div>
<?php endif; ?>

PS: we should try as much as possible to not rely on the $node object.

If you do not want any additional db_query, and the only person who'll be able to edit is User 1, use this:

<?php if ($links): ?>
  <div class="links"><?php print $links; ?></div>
<?php endif; ?>

<?php global $user; if ($user->uid == 1): ?>
  <div><?php print l('Edit', 'node/' . $nid . '/edit'); ?></div>
<?php endif; ?>

 
 

Drupal is a registered trademark of Dries Buytaert.