As per #473268: D7UX: Put edit links on everything -- and see also #606608: Use proper menu router paths for comment/* -- but actually a good cleanup in its own right.
Block module defines these two router items:
$items['admin/structure/block/configure'] = array(
'title' => 'Configure block',
'page callback' => 'drupal_get_form',
'page arguments' => array('block_admin_configure'),
'access arguments' => array('administer blocks'),
'type' => MENU_CALLBACK,
'file' => 'block.admin.inc',
);
$items['admin/structure/block/delete'] = array(
'title' => 'Delete block',
'page callback' => 'drupal_get_form',
'page arguments' => array('block_custom_block_delete'),
'access arguments' => array('administer blocks'),
'type' => MENU_CALLBACK,
'file' => 'block.admin.inc',
);
Then, in the page callback function, it searches for the (undeclared) 5th and 6th parameters in the URL, which are the block module and delta to be configured/deleted.
For proper consistency, we need to rename these URLs to follow the more standard Drupal pattern, e.g. something like:
admin/structure/block/manage/%/%/configure
admin/structure/block/manage/%/%/delete
Note that I added "manage" as one of the URL parameters to avoid possible conflicts with other URLs in the module (e.g. admin/structure/block/list).
Comment | File | Size | Author |
---|---|---|---|
#30 | drupal.block-menu.30.patch | 5.54 KB | sun |
#29 | block.patch | 5.54 KB | catch |
#24 | drupal.block-menu.24.patch | 5.54 KB | sun |
#19 | 606640-19-eojthebrave-block_router_paths.patch | 27.6 KB | eojthebrave |
#14 | 606640-14-eojthebrave-block_router_paths.patch | 27.06 KB | eojthebrave |
Comments
Comment #1
sunsubscribing
Comment #2
sunsubscribing
Comment #3
eojthebraveLets see how the bot likes this.
Comment #4
sunWe should convert these into local tasks already.
I originally envisioned to use
admin/structure/block/manage/%block/%/configure
here, along with a
'load arguments' => array(5),
and introduce a new
function block_load($module, $delta)
that loads and returns the $block from the DB.
Not sure whether that complicates things...
Aside from that, this patch looks pretty straightforward.
I'm on crack. Are you, too?
Comment #5
David_Rothstein CreditAttribution: David_Rothstein commentedI'm not the bot, but it looks pretty good to me :)
Looks like there's an inconsistency here (you're passing an extra parameter to the page callback). Actually, I missed the distinction while writing the above issue (that this path only applies to custom blocks).... I wonder if we should actually rename this url to 'admin/structure/block/manage/block/%/delete' in that case?
A minor thing: The function signatures are currently:
Seems like the latter parameters should no longer be optional, now that we're using the menu system? (Actually it may have never made sense before that way either, in which case this can be dealt with later.)
Comment #6
effulgentsia CreditAttribution: effulgentsia commented@sun: why "%block/%"? Any reason not to use the unique bid for loading %block, and then from the block object, the page callback would have access to both 'module' and 'delta'?
Comment #7
David_Rothstein CreditAttribution: David_Rothstein commentedSeems like it might complicate... note that the two callbacks require different things here (one needs stuff from the block_custom table, one doesn't), so maybe better to not make that change in this issue?
Comment #8
David_Rothstein CreditAttribution: David_Rothstein commentedI think there are some places where we might need to construct these URLs but don't know the bid offhand (but already know the module/delta), so this would probably complicate the code in those places.... plus, the URLs would be less meaningful.
I'd vote for sticking with "%/%" to keep this patch as simple as possible :)
Comment #9
effulgentsia CreditAttribution: effulgentsia commentedFurthermore, if we start using .../BID/configure instead of .../MODULE/DELTA/configure, then we can get rid of the word "manage" from the path, because a BID is always an integer. So we would just have /admin/structure/block/BID/configure (and delete), making it more like nodes and comments.
@eojthebrave: note also, http://drupal.org/node/606608#comment-2159830. probably same should apply in this patch if converting to local tasks.
Comment #10
effulgentsia CreditAttribution: effulgentsia commentedoops. cross-posted with David. Never mind then. However, a helper function block_get_bid(module, delta) would be pretty trivial to write if the benefits were assumed to be worth it. I'm fine with the idea of KISS though, given that we're technically past API freeze.
Comment #11
eojthebraveNow uses %block and block_load.
Changed path for delete to .../manage/block//delete
Changed block/configure to MENU_LOCAL_TASK, but not block/delete since this causes every block to get a delete tab, but it only applies to custom blocks.
@effulgenstia, while I totally agree that we should get rid of the module/delta paths lets leave that to another issue. Something like #430886: Make all blocks fieldable entities
Comment #12
eojthebraveExtra white space removed.
Comment #14
eojthebraveShould fix test.
Also, changed MENU_LOCAL_TASK back to MENU_CALLBACK. The earlier change was causing some exceptions, and also caused a random "Configure block" tab to show up on block/overview page and link to nothing.
Comment #15
eojthebraveComment #16
sunNice job!
Comment #17
sunoh wait.
Comment #18
sunHere, we miss a $block['module'], it seems.
Ah, no, we're missing a /block/ before the delta, but well, since $block['module'] == 'block', we can also keep it consistent and use the variable. :)
I'm on crack. Are you, too?
Comment #19
eojthebraveFixed. With tests so it won't happen again.
Comment #20
sunAwesome! Thanks so much, eojthebrave!
Comment #21
webchickAwesome!
Committed to HEAD!
Comment #22
David_Rothstein CreditAttribution: David_Rothstein commentedSee @catch's analysis at http://drupal.org/node/607244#comment-2179262 -- the way the block_load() function is being used here seems to be not so good for performance.
We may need to go back to something like the earlier simpler approach, which did not involve using a menu loader function (but rather unnamed placeholders)?
Comment #23
catchSubscribing. The issue here is that the menu system calls all loader functions when checking access callbacks - just in case they're needed, which they're not here - so moving to anonymous placeholders ought to fix it. We can also fix it in a roundabout way by using fieldable blocks, but that's a much more complicated patch which doesn't really have anything to do with this issue.
Comment #24
sunTwo things:
1) Revert menu arguments for block configuration paths to /%/% without autoloader for $block to increase performance.
2) Introduce a missing MENU_CONTEXT_NONE constant to allow a custom module/theme to expose the "Delete" link for blocks as well.
Comment #25
catchGreat patch.
Comment #26
catchComment #27
sunNope, it's still using proper menu router paths, but no longer argument loaders.
Comment #29
catchCan't reproduce the syntax error locally, resubmitting.
Comment #30
sunbot?
Comment #31
catchComment #32
Dries CreditAttribution: Dries commentedLooks good. Committed to CVS HEAD. Thanks.