0

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.

Mark Cameron
  • 2,359
  • 2
  • 24
  • 29
  • Which modules do you use that have anything to do with this ? only cck, or also a certain gallery module ? – Jozzeh Nov 24 '10 at 09:33
  • nope no gallery modules... Just CCK, and some additional ones like Embedded Media Field. I'm thinking my problem comes from the fact that the initial story node isn't saved before I create my gallery node, and so neither path alias has been put to the database so they end up with the same one. – Mark Cameron Nov 24 '10 at 11:55
  • Why does the node gallery need a path? At best, you might want path_redirect module for this one. – Kevin Nov 24 '10 at 16:49
  • Well the path is created automatically with pathauto, but it was just getting created incorrectly, 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. – Mark Cameron Nov 25 '10 at 12:25

1 Answers1

0

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;
Ted
  • 2,211
  • 2
  • 19
  • 27
  • Thanks, I had thought of that, just not quite clean enough of a solution. Could lead to conflicts if titles are the same somewhere. prefer having pathauto do the checking and creation. 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. – Mark Cameron Nov 25 '10 at 12:26