This patch introduces the hook hook_entity_translation_save(). It's fired whenever an entity translation is saved.
The idea is to give other modules the opportunity to react on translations.
The first module which implements this is entity_translation itself to deal with path-aliases the second one is pathauto.
There's another patch (#1155132: Add Entity Translation support to Pathauto) which integrates entity_translation stuff into pathauto.
To do so I had to make a small change in the entity translation form - now it's fully compatible to the pathauto node form alteration.
Another patch (#1155128: Enhance support for tokens) for the title module ensures that the tokens are provided in the correct language while using pathauto.
| Comment | File | Size | Author |
|---|---|---|---|
| #62 | pathauto-bulk-fix-1155134-62.patch | 1.23 KB | bforchhammer |
| #59 | pathauto-bulk-fix-1155134-59.patch | 1.26 KB | bforchhammer |
| #58 | pathauto-bulk-fix-1155134-58.patch | 2.65 KB | bforchhammer |
| #46 | et_pathauto-1155134-46.patch | 765 bytes | plach |
| #45 | et_pathauto-1155134-45.patch | 973 bytes | plach |
Comments
Comment #1
das-peter commentedI rewrote the patch after Dave Reid's feedback here #1155132-2: Add Entity Translation support to Pathauto
Besides the new hook the module contains now a lot more pathauto specific stuff. I tried to keep it as generic as possible but since pathauto works with predefined entity_types I had to use some ugly conditions.
Comment #2
das-peter commentedFound some issues while writing tests.
Comment #3
plachThis looks great, thanks! Sorry for not being able to have a deep look to this yet. My only concern with the current approach is about having so much explicit dependencies on pathauto and nodes, when ET aims to handle entities in a general way.
However, sunday I'll have a full day to spend on Drupal and we should be able to move forward.
Comment #4
joostvdl commentedsubscribe
Comment #5
joostvdl commentedPatch from #2 doesn't work with latest -dev release anymore
Comment #6
calculus commentedsubscribe
Comment #7
das-peter commentedRerolled to work with latest pathauto and entity_translation version.
Comment #8
das-peter commentedAdded support for redirect module and some cleanup.
Comment #9
das-peter commentedSmall fix for pathauto integration:
Pathauto handled new translation like existing nodes - this caused wrong initial settings. Now the dummy object passed to pathauto "emulates" a new node when adding a new translation.
Comment #10
das-peter commentedJust a second ago I got a ticket from a customer, asking where to set the pathauto settings in a translation.
Thus changed the name of the fieldset from "URL Alias" to "URL path settings" for the sake of consitency. :)
Comment #11
renat commenteddas-peter, your patch from #10 works just great for me! I successfully updated aliases for my nodes (each of them in 3 languages). New node creation and translation is also OK.
Would be great, though, if it will be possible to add taxonomy support in future.
Comment #12
renat commentedLooks like I found a minor bug. We have entity translatable node type, for which we didn't add rules for alias creation (and there are no default rules applicable), i.e. it is impossible to make alias programmatically for it. In case you'll add node of this type, and then will try to translate it, you'll receive this message after translation submission:
Notice: Undefined index: pathauto in entity_translation_entity_translation_save() (line 571 of /var/www/test2.sky37.com/public_html/sites/all/modules/entity_translation/entity_translation.module).
If alias automatic creation is possible, but you'll suspend it with "URL path settings" for this node, there will be no problem.
Comment #13
das-peter commentedHi renat, thank you for your feedback in #13 - the attached patch contains a fix for the mentioned notice.
Unfortunately I can't give you a time-line for taxonomy support. It shouldn't be a huge thing but I've to take a closer look first.
Comment #14
renat commenteddas-peter, hi. Patch from #13 completely solved this problem, thank you.
Comment #15
jakonore commentedsubscribe
Comment #16
giorgosk#13 patch works great
please commit
Comment #17
plachI'm sorry I couldn't work on this yet, but the patch albeit working cannot be committed as is, explained above.
Comment #18
Pisco commented@planch can you explain further where you see problems and what you would like to change, so that others can help? This issue seems somewhat stuck.
Comment #19
plachThe problem with the current approach is that it involves making a lot of special casing for nodes, while ET aims to handle entities in ageneral way. I'm seriously considering to use CTools to solve the different entities needs though plugins. But this obviously is a thing that must be carefully considered, the only problem is I am very busy with translatable fields in core to work on ET at the moment.
Comment #20
plachComment #21
jeff.maes commented+1 for patch in #13 ! Thanks!
Comment #22
Cyclodex commentedsubscribe
Comment #23
brycesenz commentedsubscribing.
I applied the patch in #13, which worked fairly well. However, I'm getting a bug - now when I go to bulk update my alias settings (URL Aliases->Bulk Update), the checkbox to update all content is missing. Is anyone else seeing this error?
Update: I cleared the cache and this was fixed.
Comment #24
plachThi is likely to be addressed in a totally different way, see #1282018: Improve UX of language-aware entity forms.
Comment #25
giorgoskbased on #13 patch here is a patch that applies to the latest dev of this module (from 2011-10-11)
Comment #27
stano.lacko commented#25: entity_translation-add-hook-for-translation-event-1155134-20.patch queued for re-testing.
Comment #29
zambrey commentedRerolled patch as the one at #25 doesn't want to cooperate :)
This is very handy feature. Let's get this in.
Comment #30
matt3om commented#29 works well.
Comment #31
zoltán balogh commented#29 works very well. Thanks, it is a very important feature!
Comment #32
plachI'm sorry but this won't be committed as is, see #24.
Comment #33
das-peter commentedI'm sad to see that this is postponed.
While I understand that we should go for "that one and only clean approach", I don't get it why this goal is more important than "have (temporary) working solution".
Especially because I can't believe that #1282018: Improve UX of language-aware entity forms will be ready soon and since there is this nice hook "hook_update_N()" which would perfectly support us migrating from the temporary to the perfect solution if it's ready.
Comment #34
plachI'm working hard on #1282018: Improve UX of language-aware entity forms to have at least the functional side ready soon. I'm wary about committing a temporary fix because people might start heavily relying on it. However my plan is to release a second alpha before committing the UI revamp. If it won't be (functionally) ready in a week I'll commit this.
Comment #35
das-peter commentedOk, that's a statement :) Thank you very much, I appreciate this!
Comment #36
plachI'm sorry but the patch cannot be committed as is:
Typo
Wrong comment wrapping. Can we have a less colloquial comment? Also below.
Wrong indentation.
Typo
This sentence looks odd.
Missing example.
Missing parameter documentation.
Typo
Missing trailing dot.
Missing trailing dot.
Comment #37
das-peter commentedThanks for the feedback.
The attached patch should fix all the things you mentioned.
Comment #38
plachOk, committed and pushed to the 7.x-1.x branch. Putting back to 'postponed'.
I did not the test this, I'm just confident this is actually RTBC as per the comments above. Everyone be warned that once the new UI is committed this might be reverted entirely.
Comment #39
das-peter commentedThank you very much!
For removing it later I suggest a two step approach.
As soon as pathauto / redirect work with the new UI we remove the integration of those modules, but keep
hook_entity_translation_save()for another cycle - giving other modules / dev's time to adapt.The really ugly part is the recycled form parts of other modules - the hook itself is not that bad ;)
Comment #40
kristen polI just installed the *dev* version of entity_translation (dated Jan 12, 2012) and am using Pathauto 7.x-1.0. The automatic path aliases are working as expected.
Thanks!
Kristen
Comment #41
colanThe second last stanza is problematic:
The last line produces
end() expects parameter 1 to be array, null given in entity_translation.module:749because $nids does not exist outside the scope of the above foreach() loop. Due to the lack of documentation here, it's difficult to determine if $language_nids should be used instead, or if that line needs to be moved into the loop (at the bottom).So this needs some work, but leaving as postponed as this can be taken care of whenever this issue get un-postponed. (However, it is currently broken in the dev branch, as this is already committed.)
Comment #42
suppyx commented#29: entity_translation-add-hook-for-translation-event-1155134-29.patch queued for re-testing.
Comment #43
klonos...this is NW based on #41. We can set it to NR once we have an actual patch ready for review.
Comment #44
Wolfgang Reszel commentedI use the path pattern [nodesymlink:menu-link:parents:join:/]/[nodesymlink:menu-link:title], but I'll only get the path of the source language. There's even no foreign language path created.
Comment #45
plachHere is a patch rolled against the ml_edit_form branch. Obviously it won't pass tests until it is merged in the main one, thus setting to postponed.
The juicy one is in the Pathauto queue, please review/test it: #1155132-18: Add Entity Translation support to Pathauto.
Comment #46
plachThe previous patch did not work without having access to the pathauto widget.
Comment #47
plachCommitted and pushed to the 7.x-1.x branch, thanks for your efforts!
Comment #48
klonosFINALLY! Thanx, ...one less patch to babysit ;)
Comment #49
plach:)
Comment #50
brycesenz commentedI'm running the latest -dev versions of Entity, Entity Translation, and Pathauto. I have several nodes with translations using this module, and none of their translations have aliases generated with Pathauto, regardless of how many times I clear the cache or regenerate the aliases.
Has anyone else experienced this, or does anyone have any thoughts on what could fix this issue?
Comment #51
plachYou need to patch pathauto, see #1155132: Add Entity Translation support to Pathauto.
Comment #52
nikosnikos commented@brycesenz yes I have the same problem. I reported it here in pathauto queue.
Comment #53
plachReopening since we are missing bulk updates.
Comment #54
plachFYI, CRUD hooks have just been reintroduced in #1224590: Introduce entity translation CRUD hooks.
Comment #55
plachComment #56
plachComment #57
colan#867578: Add drush commands for bulk alias updating/deleting is related. I was looking at ET issues when I was working on it.
Comment #58
bforchhammer commentedHere's a stab at adding support for pathauto bulkupdates...
Comment #59
bforchhammer commentedUh, last patch contained other stuff as well. Here's the proper one.
Comment #60
plach#59: pathauto-bulk-fix-1155134-59.patch queued for re-testing.
Comment #62
bforchhammer commentedReroll against HEAD.
Comment #63
plachCommitted and pushed with some adjustment, thanks!
Comment #64
plachAnd a small follow-up.
Comment #66
eidoscomSorry for reopening the closed issue. I'm not exactly sure if I must post it this here but here it is...
The "patch" is not working with almost taxonomy related tokens. (I'm using the 7.x-1.0-beta2 version with patch included).
I have a token pattern like this:
[node:field-myfield:parents:join-path]/[node:field-myfield]/[node:title]and when bulk updating the aliases get the original language tokens only of[node:field-myfield:parents:join-path]and[node:field-myfield]tokens.Is perhaps a new issue related to tokens?? Thanks
Comment #67
plachIna ny case you should open a new issue, since this one was only about introdcuing the functionality.