Hi,

Over the past days, I've been fighting nodequeue and translations. The project I'm working on, only allows management (adding/removing nodes) from the queue itself (admin/content/nodequeue/). Yet, we noticed that adding nodes through the autocomplete form keeps resulting in erratic behavior.

How to reproduce:

1. Install nodequeue and translation helpers
2. make sure you have i18n enabled and a translated node (try it with three languages)
3. Create a queue and enable 'Treat translation nodes as a single node' for that queue
4. add the translated node to the queue through the autocomplete form on the queue management page
5. On the corresponding view: add the 'node: source translation' per the instructions of Japser Knops' (http://drupal.org/node/433930#comment-2759852)
6. Add the 'Node translation: Content negotiation' filter.

Now run the view and look at the output. Depending on how you've configured your site to do multilangual support, the list will return the correct translated node for one language but not for another language.

The problem is the autocomplete box on the queue management form. The nodequeue_api_autocomplete function returns a list of nodes wit their nid's and node titles. With i18n support on, a rewrite of the query is performed which results in a set of node translations for the current language.

What nodequeue stores in the nodequeue_nodes table are those nid's of those node translations.

This causes problems on the views side: nid's of node translations who don't match the current language at that point (when viewing the queue) will still be shown or - depending on how you tried to configure the view - be removed by any Node translation filters you might try to use.

So, if you're managing the site in english and you add a translated node to the queue with 'Treat translation nodes as a single node' on, it will show that english node in the view when someone visits the french version of the site.

How to solve?

When 'treat translation nodes as a single node' is selected, nodequeue's autocomplete form should return the tnid's instead of the nid's of the listed nodes. The tnid of the node gets stored in nodequeue_nodes and Views can work it's magic through Jasper Knops' excellent relationship solution.

Weird thing is that the 'Add to nodequeue' and 'Remove from nodequeue' functions actually got this correct. Nodequeue has a nodequeue_get_content_id which fetches the tnid or nid depending on the i18n setting of the node transparently.

Anyway, patch attached solves this issue for me.

Comments

j0sbeir’s picture

Hi, thanks! your patch solved the exact same issue i was having. Still not sure how to include untranslated nodes too but i guess i can live with that.

jaydub’s picture

Status: Active » Needs review
netsensei’s picture

Status: Needs review » Needs work

Just noticed an issue with the patch.

Try this:

1. Create a node and 3 translations
2. Switch language to anything but the source language in which the node was created
3. Add the content to the nodequeue with my patch
4. Check your view.

You'll notice that the node will not be displayed.

Translations work with a 'source' node and subsequent translation nodes. All are coupled with a common tnid which is in fact the source node nid.

The problem is the 'content negotation' filter on the view side which tries to match the nid of the added translated node in the queue to the tnid which gets stored in the nodequeue now. Obviously, those don't match. Hence the node will not be shown.

Thus, you need to switch to the source language in which you created the node before you can add it to the queue. Only then it will be displayed in the view.

henrijs.seso’s picture

subscribing. at first there were no problems but once i created multiple languages and start mixing nodes with different languages + language neutral nodes I cannot get autocomplete to work (I actually dont use translations, just different nodes with different language settings).

this from OP is true however, thats the only way I can add nodes now: Weird thing is that the 'Add to nodequeue' and 'Remove from nodequeue' functions actually got this correct

Will try to test patch.

amateescu’s picture

Version: 7.x-2.x-dev » 6.x-2.x-dev
Status: Needs work » Needs review
StatusFileSize
new2.47 KB

@netsensei, I cannot reproduce the behavior from #3 (maybe the views filter was fixed in the meantime), so here's an updated patch for 6.x-2.x-dev that should fix the autocomplete problem.

The difference from yours in the OP is that I added an extra condition to check if we should load the tnid or not.

amateescu’s picture

Hmm, I guess that condition is not needed after all. So I simplified the patch (returned to the one from the OP) and commited the attached patches to 6.x-2.x and 7.x-2.x.

http://drupalcode.org/project/nodequeue.git/commit/acf6ee6
http://drupalcode.org/project/nodequeue.git/commit/36e4622

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.