Add an "Edit" Tab to Every Block

Last modified: April 17, 2008 - 17:37

Extending the idea of the post (http://drupal.org/node/120334) about "Add an Edit this Block link", I went a step further to have the edit link look like the tabs for View, Edit, etc. Here is the code that you would include in your theme's block.tpl.php file:

<div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="clear-block block block-<?php print $block->module ?>">

<?php
 
if ($block->module == 'block'):
    if (
user_access('administer blocks')) :?>

    <div id="tabs-wrapper">
      <ul class="tabs primary">
        <li class="active">
          <a class="active" href='<?php print check_url(base_path()) ?>admin/build/block/configure/<?php print $block->module;?>/<?php print $block->delta;?>'>Edit</a>
        </li>
      </ul>
    </div>
    <?php
   
endif;
  endif;
?>


<?php if (!empty($block->subject)): ?>
  <h2><?php print $block->subject ?></h2>
<?php endif;?>

  <div class="content"><?php print $block->content ?></div>
</div>

If you haven't dismissed the standard style sheets, this should produce an "Edit" tab above each block for users who have "administer blocks" privileges.

Does anyone know how could I

ipwa - August 13, 2008 - 14:55

Does anyone know how could I apply this to 5.9? I also tried this http://drupal.org/node/120334#comment-623801 and it didn't work either.

Nicolas
-------------------------
http://nic.ipwa.net

I think if you just did in

luyendao - October 9, 2008 - 16:59

I think if you just did in this in 5.x it'll work, I'm pretty sure all the code in here will work in 5.x, but I could be wrong.

<?php

if (user_access('administer blocks')) {
print
l('edit block','admin/build/block/configure/' . $block->module . '/' . $block->delta);
}
?>

Web Developer / Drupal Munkey
Randomlink Interactive Inc.
www.randomlink.net

 
 

Drupal is a registered trademark of Dries Buytaert.