Comments

bojanz’s picture

Status: Active » Needs review
StatusFileSize
new2.41 KB

It's a bit hacky, but it's the best I could think of.

This allows taxonomy term references to be used as Commerce attributes on the add to cart form, and the node add / edit form.

plach’s picture

Status: Needs review » Needs work

Overall looks good to me, thanks, a couple of remarks:

+++ b/title.module
@@ -83,6 +85,60 @@ function title_entity_info_alter(&$info) {
+ * Override the options list callback of taxonomy term reference fields
+ * with one that provides translated term names.
...
+ * Override the options list callback of taxonomy term reference fields
+ * with one that provides translated term names.
...
+ *
+ * This is a copy of taxonomy_allowed_values() that ensures that
+ * taxonomy_get_tree() does an entity_load(), causing title replacement
+ * to happen.

PHP docs are not wrapping correctly at column 80.

+++ b/title.module
@@ -83,6 +85,60 @@ function title_entity_info_alter(&$info) {
+    drupal_write_record('field_config', $record);
+    field_cache_clear(TRUE);

Why can't we use field_update_field() here?

+++ b/title.module
@@ -83,6 +85,60 @@ function title_entity_info_alter(&$info) {
+    field_update_field($field);

Why this isn't causing recursion? ;)

bojanz’s picture

I intentionally tried to avoid using field_update_field(), in order to avoid refiring all the hooks for the save.
The recursion doesn't happen because in the second run $field['settings']['options_list_callback'] is not empty anymore.

I'll do a new round of work on the patch.

plach’s picture

Status: Needs work » Reviewed & tested by the community

I'll do a new round of work on the patch.

Nevermind, I'll fix those on commit :)

bojanz’s picture

StatusFileSize
new2.49 KB

Okay, figured out why drupal_write_record didn't work inside title_field_update_field, because field_update_field places a copy of the data inside $field['data'].
Now fixed, so both hooks match.

plach’s picture

Thanks!

Reminder for me: this still needs comment fixing ;)

bojanz’s picture

That's odd because for me the comments wrap just fine, before line 80.

plach’s picture

Yep, but they should wrap as close to column 80 as possible :)

bojanz’s picture

Ah, okay, I misunderstood.

bojanz’s picture

Question: What should we do with taxonomy term references created before Title was installed?
Should we have an install hook?
Update function?
Batch somewhere?

Feels clumsy to just tell people to resave all of their fields manually.

plach’s picture

Well, an update function sounds as the way to go, but it's the kind of stuff that usually leads to unpredictable failures. Since we are still in alpha stage and the upgrade path is best-effort level, I might be ok with this fully working only on new installations.

bojanz’s picture

So, a hook_install then?
This might need a batch though...
(Or we can do it by best effort and only process the first 20 or so, dunno)

plach’s picture

Status: Reviewed & tested by the community » Needs work

Yep, hook_install() + batch sounds the right way...

muschpusch’s picture

I would like to use this patch but will it work when title is already installed?

bojanz’s picture

Yes, but you need to resave your taxonomy term reference field (click edit in "Manage fields", and submit the form).

vasike’s picture

Status: Needs work » Needs review
StatusFileSize
new3.71 KB

i did some work on the last patch trying to include also in the install and update scripts.
check the patch attached.

i'm not sure about taxonomy term reference fields Features built/defined.
probably they need the new setting to be present in feature definition.

Stevel’s picture

Doesn't it make more sense to fix this in the taxonomy_term_reference field to properly load the entity? That would also help for things like field translation etc.

mibfire’s picture

Issue summary: View changes

These patches dont work with dev version of title module:

PHP Fatal error: Cannot redeclare title_taxonomy_allowed_values() (previously declared in /title.module:139) in /title.module on line 1062

mibfire’s picture

StatusFileSize
new55.42 KB
new101.13 KB

Something strange is happening here. I applied the patch(2013985-fix-taxonomy-terms-16.patch), ran the update, and now i cant translate or delete my terms! I can create new one and translate it.

Take a look at the images what i attached here: terms-in-hungarian-lang.png, term-page.png

If something isnt clear or i should provide more info, just let me know, thx!

mibfire’s picture

bojanz,

Yes, but you need to resave your taxonomy term reference field (click edit in "Manage fields", and submit the form).

And you have to disable the i18n_taxonomy(Taxonomy translation) module!

mibfire’s picture

I realized that i cant use taxonoy menu module if i18n taxonomy is disabled(it could be used if i set the menu to "localize and translate", but there is an issue, cos in this case the taxonomy menu if i check the rebuild option and save the vocabulary the translated terms wont be associated to the source menu item, so only the source lang of the terms will be built as menu items)

I had to fix this in title module: When i18n taxonomy is enabled the "title_taxonomy_term_reference_field_options_list_callback" can happen only when empty($field['settings']['options_list_callback'] is empty, but this wont be empty cos i18n_taxonomy will set it when it is enabled by using "i18n_taxonomy_modules_enabled", so i have to check if taxonomy term is enabled in entity translation, and if yes we must set "title_taxonomy_allowed_values" to options_list_callback. I added the title_modules_enabled function too where title_taxonomy_allowed_values is added to options_list_callback as well.

There is a hook_field_storage_details_alter function in i18n_taxonomy which prevents title to work as was intended, so i had to add this function to title module as well and modify title_module_implements_alter to run after i18n_taxonomy.

mibfire’s picture

StatusFileSize
new6.98 KB

I created a patch for the above fix.

Status: Needs review » Needs work

The last submitted patch, 22: fix-i18n-taxonomy-2013985-22.patch, failed testing.

zekvyrin’s picture

people, can you try dev version, which includes patchfrom #1920096: Title incompatibility with the entity reference widget ?

Part of #22 patch is included ('title_taxonomy_allowed_values' function) and might help you pass tests.

thepanz’s picture

thepanz’s picture

joelpittet’s picture

Status: Needs work » Needs review

Let's see if testbot agrees.

thepanz’s picture

Status: Needs review » Reviewed & tested by the community

We're using patch in #27 intensively and it is working great!
please merge this patch :)

betz’s picture

betz’s picture

Status: Reviewed & tested by the community » Needs review

back to review

itamair’s picture

The #30 worked for me, but just after disabling (and uninstalling) the Taxonomy translation (i18n_taxonomy) module

pifagor’s picture

Status: Needs review » Needs work