Proper Way to Update a Node's Path Programatically in Drupal 6
I am editing a node's path programatically like this in Drupal6:
$node = node_load(3);
$node->path = 'some/new/path';
node_save( $node );
That of course works, but the old alias remains. What's the best way to do this? I see no path functions or pathauto functions to remove the old alias. Or do I 开发者_开发知识库simply need to remove the alias using SQL on the url_alias table?
You shoud use path_set_alias
To update a path, take a look at path_nodeapi, e.g. :
path_set_alias('node/' . $node->nid, $node->path, isset($node->pid) ? $node->pid : NULL, isset($node->language) ? $node->language : '');
精彩评论