Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proper Way to Update a Node's Path Programatically in Drupal 6

Tags:

path

drupal

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?

like image 589
Aaron Avatar asked Nov 22 '25 07:11

Aaron


1 Answers

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 : '');
like image 139
soju Avatar answered Nov 24 '25 09:11

soju



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!