5

I am using Pathauto. When I deleted a piece of content, I was surprised to find that its url alias was still mapped to the now-nonexistent content (node/xxx).

How can I have this alias and System name mapping removed automatically when the node is deleted?

Edit: I want to keep the Update action set to "Do nothing. Leave the old alias intact.", because I don't want paths to change when nodes are adjusted. However, it doesn't make sense to keep a path around if the node was deleted completely. Can I have both options somehow?

6

You can use hook_node_delete:

function hook_node_delete($node){
    // Delete alias.
    $path = path_load(
      array('source' => 'node/'.$node->nid)
    );

    path_delete($path['pid']);
}
2

You can update aliases here, or on the node

/admin/config/search/path

or bulk update a whole bunch here

/admin/config/search/path/update_bulk

based on an alias pattern change set here

/admin/config/search/path/patterns

I imagine the reason it "Seems" like an alias didn't delete is because it have forwarding to another alias in a sort of chain. Drupal does clean up alaises on content delete, ou can do a simple test and see it happen. But if you have alaises chained it only seems to delete the final alais and leave the others. I think if you update you "update actions" you can minimize the number of extra alaises created.

Go here and find the section called "Update action" /admin/config/search/path/settings

You have three choices of what to do when an alais changes

  • Do nothing. Leave the old alias intact.
  • Create a new alias. Leave the existing alias functioning.
  • Create a new alias. Delete the old alias.

Also based on there advice "Considering installing the Redirect module to get redirects when your aliases change."

I hope this helps ans isn't off base but I faced similar issue on a site with 500k items and the clean up was a serious issue. Best of luck!

  • Lots of info in this answer, but I've looked through all those options. Still don't see anything that answers the question. – digitgopher Feb 3 '15 at 0:27
0

You can update the path aliases here in the Admin > Config menu: admin/config/search/path/update_bulk

  • This neither removes the mapping nor is automatic... – digitgopher Jan 27 '15 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.