I see that Scald has been integrated with Entity Translation. However, at present atom titles are not fields, so they cannot be edited and made translatable, and if I access the 'Translate' tab for an atom, it tells me that my atom has 'No translatable fields'.
I can think of a workaround, where a provider has a new field for the title, and then implements hook_preprocess to replace the title with the currently applicable title (avoiding caches). But it would be better if the Title module could be made to apply to atoms as well.
Is any work under way to make this happen, or should I attempt a patch for either Scald core or Title? Or would they cause other complexities so that it is better if I just try to create a workaround? Any suggestions welcome. Thanks.
| Comment | File | Size | Author |
|---|---|---|---|
| #30 | 2211409-interdiff-28-notest.txt | 1.2 KB | jcisio |
| #27 | 2211409-title-et-27-interdiff.txt | 1.98 KB | nagy.balint |
| #27 | 2211409-title-et-27.patch | 6.55 KB | nagy.balint |
| #23 | 2211409-title-et-23-interdiff.txt | 3.5 KB | jcisio |
| #23 | 2211409-title-et-23.patch | 6.44 KB | jcisio |
Comments
Comment #1
martin_qAnswering my own question here, closer inspection of Title suggests I simply need to implement some of the functions in title.core.inc for Scald atoms, so I will try that out and report back.
Comment #2
martin_qI have been able to integrate Scald with the Title module by adding a few elements to the scald atom's entity info (see attached patch), based on the (woefully undocumented) existing applications of the Title API in title.core.inc.
To translate Scald titles, you have to:
There are a few things which are not yet quite right, though.
1. When adding new translations of an atom, the form has to be submitted twice, before Drupal redirects to "View" the atom (though it is saved with the first Submit).
2. Deleting translations of atoms is not currently possible - the 'delete' link on the Translate tab will delete the whole atom.
3. When translations of a translatable atom are saved (including the source version, i.e. the original atom), the following notices are shown:
I was able to change line 1278 from
to
and line 1283 from
to
which solved the problem for atoms, but is obviously not a solution because it would break entity translation for everything else. The question here is, is this a bug in entity_translation or in scald?
4. A note on the side: entity translation does not yet work on taxonomy fields of scald atoms (i.e. authors and tags). If this is enabled, the following errors occur upon submitting an atom:
I presume the later errors are a result of the problem described in the first notice, but I could not really work out the problem. I discovered I was out of my depth in terms of how entity widgets work.
Comment #3
martin_qAaargh! I wish I had checked that patch before posting it. As a git noob I obviously did the wrong diff. Correct patch now attached. My apologies.
Comment #4
jcisio commentedSo, the ET integration (and its problem) aside, let's concentrate to Title integration in this issue. Patch looks great and it works. It really love to see that we could have some tests for it (with or without the locale module).
Comment #5
shortspoken commentedI just tested the Title module integration and it works good. Although when replacing the title field the original content does not get copied into the new title_field.
And I can confirm that it needs two clicks when saving a new translation. Any suggestions how to get rid of this @jcisio?
Tested with Scald 1.3, Drupal 7.34, Title 7.x-1.0-alpha7 and Entity Translation 7.x-1.0-beta4
Comment #6
nagy.balint commentedActually the dev version of the title module and ET module should be used.
Because both had a lot of changes since the last stable version, but mostly the title module where the last stable version was 2 years ago.
In the dev of title i get the following two errors with this patch:
Warning: Invalid argument supplied for foreach() in title_field_sync_get() (line 492 of /sites/all/modules/contrib/title/title.module).
Warning: Illegal string offset 'title' in title_entity_label() (line 130 of /sites/all/modules/contrib/title/title.module).
Comment #7
nagy.balint commentedHere is a new patch for the title module dev version.
The functions return value has changed slightly, however so far i cant create a translation it goes to a bad request. So remains needs work.
Comment #8
nagy.balint commentedHere is another patch that solves the broken translation add/edit links.
Because the following edit path will not work:
'edit path' => 'atom/%scald_atom/edit/%ctools_js',
As we cannot manage translations in the ctools modal anyways. And on the atom page tabs, the %ctools_js placeholder will never be solved.
Its still not ready, i will need to do some more tests on a fresh site.
Comment #9
nagy.balint commentedSo far it works fine and It seems i dont have issue number 1 where i would need to double save when adding a translation.
So far the problems are :
1. Cant change the title
2. Deleting translation does not work.
Comment #10
nagy.balint commentedAs far as I can see the issue with 2. is that the entity form does not have a delete button, and so entity translation cannot override the button to be the translation delete button.
Comment #11
nagy.balint commentedThe patch attached will also solve the translation deletion issue, by adding a delete translation button.
This also required to implement our own handler extending the default handler.
Now the only thing left to fix is to be able to change the title. Likely an error somewhere in the code at sync.
Comment #12
nagy.balint commented+1 issue i found is that
if 'edit path' => 'atom/%scald_atom/edit/%ctools_js',
Then the ctools edit pages works
if its the new value 'edit path' => 'atom/%scald_atom/edit',
then the links on the translate tab works.
So will need to find some solution to make both work.
Maybe with path schemes but not sure yet how to set that up.
Comment #13
nagy.balint commentedThe attached patch works better.
It fixes the issue with the %ctools_js, although not sure if it can be considered as a clean solution.
Also fixes the issue with the title not updating.
However the title field still seems to act up when there is no translation is added, and the user changes the default language value while changing the title.
Comment #14
nagy.balint commentedPutting needs review to trigger the bots.
Comment #15
nagy.balint commentedThe other issue the patch has, is that when creating new atoms, the current code prefills the title, however it wont prefill the new title field.
Comment #16
nagy.balint commentedTo fix the prefill i added the following form alter in scald.module
And the following addition in the ScaldAtom construct after the values array definition
Unfortunately even though this seems right and the atom then correctly gets created by the default language specified in entity translation settings, the atom created this way is not possible to translate :( Because when i try to add a new translation it will just overwrite the original language version.
Comment #17
nagy.balint commentedOkey the bug is not related to the code in #16
It is related to the fix in #13 where i replaced the %ctools_js out from the getEditPath in the handler.
Apparently if %ctools_js is in the entity info originally and since getEditPath does not run in all cases, then adding a new translation will not work, cause ET cannot attach itself to the edit page...
No idea why is it soo difficult to make it work.
Maybe it has something to do with the entity not being entity api based.
Comment #18
nagy.balint commentedI think I'm postponing this until after 1.4, as i see no point including title integration when the ET integration is such a mess...
Comment #19
nagy.balint commentedComment #20
mr.york commentedFixed ET generated url and attached #16 code.
Comment #21
mr.york commentedComment #22
jcisio commentedI'll review this patch.
Comment #23
jcisio commentedI've removed the most annoying customization from Title (the sync set/get part). With our workaround sync_set, we lost backward compatibility e.g.
$atom = scald_atom_load(1);$atom->title = 'Test title';scald_atom_save($atom);won't work (thanks to @DeFr). Now everything is OK in my test. Plupload integration still works, too.I'm waiting for another round of feedback and then commit this patch.
Comment #24
nagy.balint commentedI will have a look tomorrow.
Comment #25
jcisio commentedI've read the patch again and just found that in scald_form_scald_atom_add_form_options_alter() we need to adjust the check in the same way as in title_field_replacement_info() of the last patch. module_exists('title') is not enough and title_field is hardcoded which is not always correct. I can't test right now so I'm not making another patch until this weekend.
Comment #26
nagy.balint commentedIt seems to me that even the title_field_replacement_info() is not enough. Because it is possible that I enabled the title replacement for a specific bundle only, like image, but did not enable it for videos lets say.
Comment #27
nagy.balint commentedSomething like this should solve those issues.
Comment #28
jcisio commentedThat's exactly it! I've rewrite the if condition because with the helper function from Title, we can write it shorter. Committed and pushed. Thanks all for this collaborative work!
Comment #30
jcisio commentedThe interdiff for reference.