Put edit block links on blocks for easy use by administrators
UPDATE: The Zen Theme does this so, so much better, so we'll be stealing from it as soon as we get the chance.
Provide edit links to block and view blocks for admin users by modifying block template files in your theme.
This is very rudimentary but works for the most common blocks. I'm sure it can be generalized to work for all blocks no matter what module defines them.
Create edit-block.tpl.php
<?php
if (
(($block->module == "block") && (user_access('administer blocks'))) ||
(($block->module == "views") && (user_access('administer views')))
):
?>
<div class="administer">
<a href="<?php print check_url(base_path()) ?>admin/build/block/configure/<?php print $block->module;?>/<?php print $block->delta;?>">Edit this block</a>
</div>
<?php endif; ?>
Then include in the various block templates you may have and for which you want edit links. (Do not use include_once, you want it to appear for every block!)
For instance, here's our block.tpl.php:
<div id="block-<?php print $block->module; ?>-<?php print $block->delta; ?>" class="block<?php print " block-$block->module"; ?>">
<?php include('edit-block.tpl.php'); ?>
<?php if ($block->subject): ?>
<div class="title"><?php print $block->subject; ?></div>
<?php endif; ?>
<div class="content"><?php print $block->content; ?></div>
</div>
Reference:
http://api.drupal.org/api/function/theme_block/5
http://drupal.org/node/120334
Add an "Edit this Block" link
theme('block', $block) Drupal
A related improvement that would be very nice and should be done as a module is something that could provide a link from the block editing page to any configuration handled by the module that provided the block– mostly, a link back to edit the view for Views blocks.
Resolution
More like this
- Make nodes easy to edit, even when they are embedded in a panel or teaser ist
- Use the admin theme for Drupal help pages
- Ask Agaric: Making the book block link to the parent of a book node
- Putting regions and blocks in Drupal nodes
- Having the top-level menu items not be links (for use with dropdown menus)


Comments
Post new comment