flag translated node IDs

tomsm - August 24, 2009 - 10:20
Project:Flag
Version:6.x-1.1
Component:Views integration
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

I have a site with 3 languages: English, French and Dutch.
Only the node id of the source language (English) is flagged. The IDs of the translated nodes (French and Dutch) are not.
As a result I only see the titles of the English nodes in my view. Normally I should see a node title for each translation and by using a views filter only the ones that correspond with the current user's language, are shown.

However the flag status is correct when I change the user interface language, for example: when I flag a node using the English interface, it is shown as flagged using other languages and vice a versa. So this works fine.

#1

tomsm - August 24, 2009 - 19:21
Component:Flag core» Views integration
Category:feature request» support request

I don't know if this issue is related to the flag core or views integration. But I have the problem with views, so I pick that one.

Some extra info:
I have set my internationalization option to "Flag translations of content as a group".

#2

vanhanit - August 28, 2009 - 14:56
Category:support request» bug report

I too have this problem.

The join for me created by Views is:

INNER JOIN flag_content flag_content_node ON node.nid = flag_content_node.content_id AND (flag_content_node.fid = 1 AND flag_content_node.uid = ***CURRENT_USER***)

For multilanguage support this should be something like:
INNER JOIN flag_content flag_content_node ON (node.nid = flag_content_node.content_id OR node.tnid = flag_content_node.content_id) AND (flag_content_node.fid = 1 AND flag_content_node.uid = ***CURRENT_USER***)

or
INNER JOIN flag_content flag_content_node ON flag_content_node.content_id IN (node.nid, node.tnid) AND (flag_content_node.fid = 1 AND flag_content_node.uid = ***CURRENT_USER***)

After this one can filter the result down with the Select Translation module.

I have tried to fix this problem myself but can't really find any good documentation on how Views Integration works from a developers perspective.

#3

quicksketch - September 14, 2009 - 13:26
Category:bug report» support request

I don't think this is a problem with the Views integration, it's probably a matter of setting up the view properly. When you tell Flag to "flag translations as a group", it actually only flags the original node, not any of the translations. So when building a view that lists nodes in any language, you will need to add another relationship for finding the parent translation, then do all your flag filtering/relationships off of the parent translation.

#4

tomsm - September 14, 2009 - 19:12

Thanks for the tip. I have found a solution:
I added the relationship "Node translation: Source translation" with as label "Source translation".
I placed it above the existing flags relationship and set its relationship to "Source translation".
The result is that all translations are shown in the view.
Then I added a filter "Node translation: Language = current user's language".

Is this the best solution?

#5

quicksketch - September 14, 2009 - 19:14

Yep, sounds perfect. I haven't worked on any internationalized websites recently, but that sounds like the same approach I used in previous sites.

#6

tomsm - September 14, 2009 - 19:44

Small problem:

If I flag a node that has not been translated yet (only the source language English exists), it does not appear in the view.

If I translate it in one language, the node appears in the view when the interface language = source and = translated language; if the interface language = not translated language, the node does not appear, which seems normal.

#7

quicksketch - September 14, 2009 - 20:31

If I flag a node that has not been translated yet (only the source language English exists), it does not appear in the view.

You should check if that node doesn't show up even without the Flag relationship/filters added to the view. My guess is that the the translation relationship isn't pulling in the nodes correctly if it hasn't been translated.

#8

tomsm - September 15, 2009 - 07:54

When I uncheck "Include only flagged content" in the flag relationship, the untranslated node is shown. So the translation relationship is pulling the node. If I recheck "Include only flagged content" the node disappears again.

When I remove the flag relationship I get an error message "An error occurred at /drupal/en/admin/build/views/ajax/preview/flag_favorite_products."

#9

vanhanit - September 15, 2009 - 10:45

I have solved this by extending views_join with my own class and added the IN join i described above. After that I use the Select Translation module to filter down the result to the best matching node language according to the logged in user.

 
 

Drupal is a registered trademark of Dries Buytaert.