Currently in zen_preprocess_block_editing(), the $edit_links_array variable is an array of links processed by the l() function. I'm not sure how useful this is, as a sub theme can't do much more than output them again with a different delimeter, or be forced to use regex to modify the link.

It would be nice if each item in the $edit_links_array were an array itself of the arguments that are passed to l(), keyed on the href of the link. This would allow sub themes (or even modules) to modify the link itself.

An example of why this would be useful is in order to use ajax on these block links, the javascript to trigger that ajax often depends on a particular css class, or the module that houses the javascript itself may need to prepend the url, or use a fragment identifier.

So, now on to the patch. One disclaimer here is that I haven't actually tested the patch, which I'll do testing on it after there's feedback on the request. Another thing is the array_merge_recursive. I'm not sure if zen's links should be the first array or the second array. IOW, should zen override any links that modules may have added, or should modules override any links that zen has added? I'm thinking the latter may be the way to go, but I'd appreciate your opinion there.

Actually, now that I think about it, array_merge_recursive may not even work. Forgive me while I think out loud:

<?php
  $vars['edit_links_array']['foo']['options']['attributes']['class'] = 'my-module-class';
  $edit_links_array['foo']['options']['attributes']['class'] = 'zen-class';

  array_merge_recursive($vars['edit_links_array'], $edit_links_array);
?>

Result:

 'class' => array('my-module-class', 'zen-class'),

Instead of overwriting the class, it would turn the class into an array. So maybe + should be used instead:

<?php
  $vars['edit_links_array'] = _zen_preprocess_block_editing_links($block) + (array) $vars['edit_links_array'];
?>

I don't know. As you can see this needs some work.

CommentFileSizeAuthor
zen_edit_links_array.patch5.53 KBq0rban

Comments

akalata’s picture

Component: Code » layout.css
Status: Needs work » Closed (won't fix)

Closing old/inactive requests.

q0rban’s picture

Component: layout.css » PHP Code
Status: Closed (won't fix) » Needs work

It's only inactive because no maintainers have responded to it.

barraponto’s picture

Component: PHP Code » layout.css
Status: Needs work » Active

Sorry for taking this long to answer the issue, James.
The edit_links_array is keyed in such a way it is easy to unset a link or substitute any.
As you can see, in zen_preprocess_block_editing there is some clever figuring of proper links.
However there are no parameters to preserve, they are all made up as needed.
I'd say all you need to do is override a link and use what's in the preprocess function as an example.
Adding a class, if that's what you need, can be done through the classes array.
If you need to do several changes like this, maybe your own subtheme can have a function that sets both class and link at once.

johnalbin’s picture

Status: Active » Closed (won't fix)