I wrote this quick hack to be inserted in pathauto.module.
/**
* Implementation of hook_node_operations().
*/
function pathauto_node_operations() {
$operations = array(
'publish' => array(
'label' => t('Update path alias'),
'callback' => 'pathauto_node_operations_update',
),
);
return $operations;
}
/**
* Callback function for updating node aliases.
*/
function pathauto_node_operations_update($nodes) {
foreach ($nodes as $nid) {
$node = node_load($nid);
$placeholders = pathauto_get_placeholders('node', $node);
pathauto_create_alias('node', 'bulkupdate', $placeholders, "node/$node->nid", $node->nid, $node->type);
}
}
It adds an option to the Node Operations the select box in admin/content/node, which updates the path aliases of the selected nodes. I suspect this can't be so easy, or it would have been done before.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | pathauto.module.patch | 443 bytes | psynaptic |
| #5 | pathauto.module.patch | 469 bytes | psynaptic |
| #2 | pathauto_219726.patch | 899 bytes | waddles |
Comments
Comment #1
gregglesCan you provide it as a patch?
Can you get someone else who uses node_operations module to test it (I don't use it and don't entirely plan on it).
Comment #2
waddles commentedYes, it really is that simple. :)
Comment #3
gregglesGreat - thanks, wad!
Committed to both DRUPAL-5--2 and HEAD (for 6.x).
Comment #4
psynaptic commentedI think this removes the Publish option from the Update options. Can anyone else confirm this?
Comment #5
psynaptic commentedChanging the name of the element seems to fix it.
Before:
After:
I can now see the Publish option in the Update options again. I have tested Updates path alias and Publish and they both work as expected.
Unified diff attached.
Comment #6
psynaptic commentedHere's another patch where I ran the patch program from the Drupal root. Hope this helps.
Comment #7
gregglesyeah, see http://drupal.org/node/226914 for the bug report on this...
Seems critical bug now and since you have the patch here I'll repurpose this issue...
Comment #8
gregglesApplied to both 5.x-2 and 6.x.
Thanks psynaptic!
Comment #9
psynaptic commentedGlad to be of service.
Comment #10
poehnix commentedPatch works
Comment #11
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #12
eaposztrofi have Pathauto 5.x-2.1, this patch is applied, and now the 'Update path alias' is missing :)
Comment #13
greggles@eaposztrof - the way you describe that sounds like a bug, but you used a smiley and left the status as closed so I'm not sure.
I can't repeat that bug (it works fine for me) so I'm not sure what this means.
Comment #14
wmclark commentedThis still seems like a bug in 2.1. Although the new functionality is added, it introduces a new bug in which you can not bulk publish nodes.
The correct patch does not to seem to have been applied to pathauto.module in the 2.1 version. I just download a fresh copy and checked the code.
After changing the code described here, I can now bulk publish nodes again.
The correct patch needs to be applied to 2.1.
Comment #15
greggles@wmclark - it was applied to 5.x-2.x-dev. Please test that release, it is quite stable now and will soon become 5.x-2.2. There is no way to apply a patch to an existing release and still have it be called 5.x-2.1...
Comment #16
wmclark commentedOk, I just manually did the patch myself. Since it is on production I prefer to leave it the "stable" version.
Thanks greggles