2 nodes with the same path when creating one programatically during creation of first

267 Views Asked by At

I have some functionality on my site where when a journalist creates an article with multiple images to make a slideshow, they can check a box which will create a node of a type "gallery" which will then contain the images to be displayed as a gallery. (Bigger layout, different carousel).

When I create the gallery node during the save of the story node after clicking the save button in the create story content form, both the gallery and the story share the same path, so they both end up with the same url and so both point to the story, and I can't access the gallery node.

I've tried performing the gallery save operation at different operations in the hook_nodeapi (presave, update, save). But no difference. I've even set certain parameters of my node object to force the path alias to run, hoping it would set it with a different one:

$node_gallery->path           = '';
$node_gallery->pathauto_perform_alias = 1;

any ideas would be welcome, thanks

UPDATE: I ended up just changing the naming settings for a gallery in the URL Alias configuration, so that it would create a path with "/gallery/" in it.

1

There are 1 best solutions below

1
On

This isn't the most elegant of answers, but if you use the nodeapi update case, you have access to the node after it has been saved and assigned a path. So ...

$new_node->path = $node->path . 0;