By giving users with permission to do this directly from blocks giving me so much easiers to configure blocks and change menu, when there are so many blocks ! Make sure clear cache to take effect.
1. Add this in template.php
/**
* Override or insert variables into the block templates.
*
* @param $vars
* An array of variables to pass to the theme template.
* @param $hook
* The name of the template being rendered ("block" in this case.)
*/
function phptemplate_preprocess_block(&$vars, $hook) {
$block = $vars['block'];
// Special classes for blocks.
$classes = array('block');
$classes[] = 'block-' . $block->module;
$classes[] = 'region-' . $vars['block_zebra'];
$classes[] = $vars['zebra'];
$classes[] = 'region-count-' . $vars['block_id'];
$classes[] = 'count-' . $vars['id'];
$vars['edit_links_array'] = array();
$vars['edit_links'] = '';
if (user_access('administer blocks')) {
include_once './' . drupal_get_path('theme', 'framework') . '/template.block-editing.inc';
phptemplate_preprocess_block_editing($vars, $hook);
$classes[] = 'with-block-editing';
}
// Render block classes.
$vars['classes'] = implode(' ', $classes);
}
2. in block.tpl.php or all your custome block
<?php
// $Id: block.tpl.php,v 1.2 2009/03/17 05:04:14 andregriffin Exp $
?>
<div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="block block-<?php print $block->module ?>">
<?php if (!empty($block->subject)): ?>
<h2><?php print $block->subject ?></h2>
<?php endif;?>
<div class="content"><?php print $edit_links; ?>
<?php print $block->content ?>
</div>
</div>
3. Add the attached file and put in the folder. Change to .inc instead.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | template.block-editing.txt | 3.7 KB | andregriffin |
| #3 | template.block-editing.txt | 3.03 KB | najibx |
| template.block-editing.txt | 2.6 KB | najibx |
Comments
Comment #1
andregriffin commentedThis is taken from Zen, yeah? I suppose it's fine to borrow some code. We're all one big happy Drupal family. I'd like to get it styled so that it doesn't impact the layout, as the space created for the link shifts things around a bit. I'll try and style it as an absolute positioned hover effect similar to Zen.
I've always thought this would be a very helpful addition, but I couldn't bring myself to yank code from other themes.
I'd like to track the author of the code to give proper credit. Is it JohnAlbin?
Comment #2
najibx commentedit's from blueprint. and yes, zen got that too....this feature is a must !
Even after trying several other base theme, somehow I stick with Framework. Thank you !
a styling would be good. It's somehow overlap with Views edit.
Comment #3
najibx commentedwould you consider [Edit tabs] from Quicktabs modules as well? I thought it's useful and very easy when it come to creating tabs.
I attached below.
Comment #4
andregriffin commentedEverything is patched and working at d6.andregriffin.com
It'll be released in 2.5. Though, it will be a while before there are enough changes for a 2.5 release, This post should be helpful enough for those who don't want to wait.
Here is the CSS for style.css
Comment #5
andregriffin commentedAlso, I'm using what seems to be a slightly updated template.block-editing.inc
Attached below: rename to template.block-editing.inc
Comment #6
najibx commentedregarding that CSS, auto appear is nice ... but in FF and chrome, whenever I mouse over it shows at the top and gone when I bring my mouse over it. so, I change to position: relative; instead. eventhough, you've covered with z-index: 40; I put margin-bottom: 15px; so in case in "Views's block " it does not overlap with [Edit] [Export] [Clone]
how about this ...
Comment #7
andregriffin commentedThe point of the absolute positioning is so that nothing adjusts to make room for the links. This will help not break certain layout elements for some themes.
I'm not having any problem with the the hover effect. I've just tested FF2, FF3, Chrome, Safari, IE7, and IE6. The only one that did not work was IE6, and quite frankly, I'm not too concerned about IE6.
I'll install views on the development site and do some testing. Thanks for the feedback and support.
Comment #8
najibx commenteduhuu ..[edit menu] not working for http://drupal.org/project/menu_block
it simplly goes to "navigation" menu list, instead of respective menu
anyone have this sorted?
Comment #9
andregriffin commentedThis feature is now included in 2.5
Comment #10
sposob commentedcau!
how can i include the [edit menu] into jquerymenu? i tried the code from above and tried it with replacing all the $block with $jquerymenu_block, as this seems to be the function for the jquerymenu blocks. i am not very good in php or anything like this.....
when i put the code into block.tpl.php my page goes blank though (also with the original code from above using the 'normal' blocks) and nothing changes for the jquerymenu altogether anyway.
i have the [configure] for the jquerymenu block, but not the [edit menu]. i use zen theme.
any ideas?
thx
sp~s~b
Comment #11
avantwaves commentedWhat about if I want to turn on/off this feature?
Thanks!
Comment #12
andregriffin commentedYou can delete the edit-links piece of PHP code in block.tpl.php to remove the functionality.
Comment #13
avantwaves commentedThank you very much!