I have created a patch that changes the way links are added. Instead of being dependant on JavaScript they are added via template_preprocess_block.
I have also added edit links for menu blocks. Clicking one of these links will take you to the relevant menu edit page to edit the menu items.
I'm really not sure if this should be committed since it would stop the module being so easy to install. All users would have to edit their block templates to add the print $block_edit_links .
Here is a sample block.tpl.php which works with the attached patch:
<div id="block-<?php print $block->module . '-' . $block->delta ?>" class="block block-<?php print $block->module ?>">
<?php print $block_edit_links ?>
<?php if ($block->subject): ?>
<h2 class="title"><?php print $block->subject ?></h2>
<?php endif ?>
<div class="content">
<?php print $block->content ?>
</div>
</div>
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | block_edit-template_preprocess_block_v2.patch | 4.13 KB | psynaptic |
| block_edit-template_preprocess_block.patch | 4.04 KB | psynaptic |
Comments
Comment #1
psynaptic commentedHere is another patch that prepends the edit links to $block['content'] so we no longer need to edit the block template files.
Comment #2
irakli commentedOoooops, sorry. Seems like I missed this one.
You are correct in that we definitely do not want to make users edit block templates. Integration must be seamless. That's why it was done with some Javascript acrobatics originally.
As far as theming links. We can still theme links, even if it remains Javascript, using theming abilities of Drupal.js (I think).
Have not thought about $block['content'], before. Does it work for any theme?
Comment #3
psynaptic commentedTotally agree we need the module to "just work" out of the box. Installing this via drush and refreshing the page makes me happy :)
It's basically the same restrictions as the existing module as the JS still needs the block ids to hook on to. If JS is disabled then the links would be present which would probably be better.
If we do use the block templates we can detect which modules generated the block and do different stuff.
I still think we need a unified method/API for adding edit/hover links to on page elements but that's probably out of scope for this module since it's called *block* edit.
Comment #4
psynaptic commentedI have committed this to DRUPAL-6--1.
As the commit message describes I also have added menu edit links.