I'm building a site that has rather large content types that produce nodes with multiple field collections. The site is multilingual and our translators prefer to make their translations by clicking on the "Edit" link for each Field collection item rather than translating the entire node all at once. The problem is, every time they save the Field Collection item, it seems to turn on the "Generate automatic URL alias" setting for the node and changes the URL. We need to keep the URLs as they are in English so this bug is preventing us from using the "Edit" feature of the individual items.
Is there a solution? Thanks.
Comments
Comment #0.0
jaydee1818 CreditAttribution: jaydee1818 commentedtypo fix
Comment #1
mawint CreditAttribution: mawint commentedThis is also an issue with version 7.x-1.0-beta7.
Just upgraded and still having this issue.
I have not found a solution yet though.
Comment #2
mawint CreditAttribution: mawint commentedI hope I did this right since this is the first time I have done this.
In the save function for field collections, just before entity_save I added the path auto function to ignore resetting the url.
Comment #3
jmuzz CreditAttribution: jmuzz commentedPatch files should contain the output of a 'git diff' command so we can see exactly what changed. Please see https://www.drupal.org/node/707484 for details.
Comment #4
mawint CreditAttribution: mawint commentedThanks for the link, does this work?
Comment #5
jaydee1818 CreditAttribution: jaydee1818 commentedI was able to successfully apply the patch.
I tested by going to an English node, and switching to Japanese via our language selector. In the Japanese node, I edited one of the Field Collection items and saved. It successfully updated the item without altering the node url. However, the Japanese node seemed to lose its relationship to the English version (and other languages).
After the initial save, the language selector was set to English, even though the node was definitely in the Japanese node. If I returned to the English node by removing the "ja" identifier from the url, Japanese was no longer listed as an option to change to. I could return by re-adding the "ja" to the url, but as I said, it seems the link has been severed.
This patch may be on the right track, but not the final solution I'm afraid.
Comment #6
mawint CreditAttribution: mawint commentedThat's good news.
I'm not using a language selector on our website so I only needed it to fix the problem of re-enabling the auto generation of the urls and resetting the URLs.
I have never used the language selector on a site however.
Comment #7
jmuzz CreditAttribution: jmuzz commentedAlso see #1187010-64: Image field malfunctioning on embedded field collection form. .
Comment #8
a.ross CreditAttribution: a.ross commentedThis is not as easy at it looks at first sight. See: #1576552: Prevent PHP notices in path_node_insert/update if $node->path is defined but $node->path['alias'] is not.. The patch in #4 naively assumes that you wouldn't want to update the node's path alias. That's probably correct in most scenarios, as path aliases are, by default, only based on node title. It's easy to imagine someone using the value of a field inside a field collection in the Pathauto pattern.
Probably the best way to handle this would be to replicate what pathauto does when it creates the HTML for the Auto Alias checkbox. That appears to be the following (not available as a function):
Comment #9
earthday47Updating the patch in #4 for the latest beta, 7.x-1.0-beta10.
Keeping the status quo, abstaining from the bigger discussion here. :)
Comment #10
nico.knaepen CreditAttribution: nico.knaepen at Logic in Motion for Colruyt Group Services commentedWhen applying a new patch, it is required to set the status to "Needs review".
Some coding standard issues:
Put space between if and (.
false should be in uppercase
Comment #11
betz CreditAttribution: betz commentedPatch rebuild for 7.x-1.x, taking into account coding standards.
Comment #12
betz CreditAttribution: betz commentedComment #13
betz CreditAttribution: betz commentedhow how, I forgot another space. Corrected.
Comment #16
nico.knaepen CreditAttribution: nico.knaepen at Logic in Motion for Colruyt Group Services commented@betz, Thanks for taking care of the coding standards.
Comment #17
jmuzz CreditAttribution: jmuzz commentedI agree with #8, it isn't sufficient to just deactivate path auto when editing field collection items. I don't think it is necessary to duplicate the option on the field collection item form but it should at least use the setting for the node, so if it's set up to use a generated URL alias the alias should be updated whenever the node is saved, even if it's done via editing one of its field collection items.
What about the issues mentioned in #5? Do they no longer occur with this patch?
Comment #18
jmuzz CreditAttribution: jmuzz commentedAre you using the latest version of pathauto? This apparently happened when using pathauto with any module that would save nodes, but it's supposed to be fixed now. #936222: Merge in pathauto_persist module functionality to prevent losing manual aliases with node_save() calls