4

I've created some nodes programmatically and set the path alias. But when I then go into edit the node the 'Generate automatic URL alias' option is still checked, even though my alias is shown in the 'URL alias' textfield underneath, so consequently gets overwritten on save.

Also, when editing the node using the Entity module and entity_metadata_wrapper(), the alias is generated again and my alias is overwritten because of this problem.

When I load a node using node_load() I expect to see $node->path['pathauto'] but I don't, so I can't seem to disable it this way. Anyone have any advice?

1 Answer 1

3

Figured I'd help out -- took me a while to find it.

Pathauto doesn't implement hook_node_load, so you won't see it there. My case was I needed to remove an alias in an update hook, and make sure that checkbox is unchecked.

So that's what I did

  $node = node_load(17);
  $node->path['pathauto'] = FALSE;
  node_save($node);
  pathauto_node_delete($node);
  node_load($node->nid);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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