I am creating a title with php, consisting of to parts:
part 1: namestring
part 2: filestring
...
more code
...
$final_string = $result . " - " . $filename;
$final_string = str_replace("%20", " ", $final_string);
return $final_string;
After saving the node gets a correct title, but the linking is broken. System tells me, that the node <$result . " - "> was created (in fact the the node was titled like expected) and that the site "content/result . " - "" was not found.
Though the creating of the title string and titleing of the node went absolutely correctly, the linking after creating the node seems to be broken.
I am using pathauto-module and global-redirect.
This behaviour is repoducible: always
| Comment | File | Size | Author |
|---|---|---|---|
| automatic-entity-label_2.png | 34.11 KB | Anonymous (not verified) | |
| automatic-entity-label_1.png | 25.78 KB | Anonymous (not verified) |
Comments
Comment #1
Anonymous (not verified) commentedComment #2
Anonymous (not verified) commentedComment #3
bforchhammer commentedAEL currently saves newly created nodes a second time in order to be able to use things like the node id which is only available after it has been saved to the database.
My suspicion would be that the 2nd part of your title (the
$filename) is a property which also falls into this category, i.e., which is only available after the node has been saved at least once (and after the respective file has been uploaded and properly added to the managed file database table?)Pathauto related functionality is only executed during the first save, so if you use [node:title] in a pathauto pattern, the incomplete title will be used. Other users have experience the same problem, but I'm afraid I don't have a solution.
So, I'd look at how you compute
$filenamein your custom php code and check if that can be changed.Comment #4
ikeigenwijs commentedI first tried to get around this issue with rules.
trigger -> on new content saved
action -> redirect
and a lot of variations, but that did not work.
Then i found the following module:
https://www.drupal.org/project/node_save_redirect
The functionality is enough for our use case.
Maybe AEL could teak a peak at how they do it.
Its also in hook_submit
I used debug and step by step execution.
I saw that the complete procedure of title generation is performed 2 times for 1 node. to get availability for all tokens like tose only available after the first node_save ,nid, serial and so on.
The solution i think is in resetting the redirect every time the title is changed. (Now its handled by path_auto_only after new content_save, so the new title after the second save does not get processed by path auto for the redirect , but the correct alias with the full correct title is created correctly)
I think in auto_entitylabel_field_attach_submit() should the new redirect be set with the correct complete title.
The how i don't know, this is as far as i got.
Comment #5
shaisamuel commentedI have similar issue:
Comment #6
Marcus 78 commentedSimplest solution to this is to use the pathauto module. Since its automatically set to [node:node-title] i guess there som trouble with "first save" of the two saves that this module makes since it refers to something that isnt there.
Change the automatic path to something else like [node:nid] or anything but the title and you avoid this error.
Comment #7
purushotam.rai commentedI guess this issue has been fixed with latest releases of these module as I'm not able to reproduce this issue anymore with current stable versions of Automatic Entity Label and Pathauto.
Everything works fine for me and hence closing this issue. Feel free to re-open if anyone encounters any such issue. It would be highly appreciated if we can have steps to reproduce as well.
Thanks
Comment #8
purushotam.rai commentedComment #9
purushotam.rai commentedComment #10
crutch commentedstill issue with 1.3
my use case is using this replacement/insertion
My-Data-Record-[node:nid]
after saving it redirects to the page http://mysite.com/my-data-record-
which it doesn't find and redirects to the first node id created with this method.
In essence always redirects to http://mysite.com/my-data-record-1 even though I just saved http://mysite.com/my-data-record-2
Comment #11
crutch commentedComment #12
cornelyus commentedSame here.. name "Marcacao - [node:nid]" , redirect to the first I created.
EDIT:
As of this, https://www.drupal.org/node/2824715 , it really is an issue with the pathauto, and having node:title token in it. Changing pathauto pattern to the one expected, solved it.
Comment #13
crutch commentedOkay great this works thank you. I used the same tokens for auto entity label and pathauto and it seems to be working well. In my case, specifically
AEL is
[node:field_select_course]-[node:nid]Pathauto is
current-courses/[node:field_select_course]-[node:nid]Comment #14
proofoftom commented