Hi all,
I'm maintaining a nodequeue where translated versions of the nodes are available.
In the setting for the nodequeue - "Treat translation nodes as a single node" is selected.
The logic here is that if a queue is re-ordered/added to, then that would be reflected in all languages.
Is that correct?

Using the default view provided by nodequeue, only Nodes in English [base language] are provided.
path nodequeue/2
I added the view to a menu, and then translated that Menu item to Spanish.
However when view is displayed in Spanish
path es/nodequeue/2
no nodes are displayed.

Expected behaviour [from me !] would be to display the translated versions of the nodes.
Is there anyway to configure that behaviour?

Regards
Alan

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stella’s picture

subscribe

alanburke’s picture

I should add that I'm using i18nviews module, with the 'Content negotiation' filter in the views.

rolando.isidoro’s picture

Issue tags: +translations

Hi Alan,

I'm facing the same problem as you, at this point I still can't quite figure out how Nodequeue handles translated nodes. The only way I managed for the nodes to show up in a single nodequeue view in two languages was to:

  1. Create node in one language and add to the queue;
  2. Create node in the second language and add to the same queue;
  3. Assign the translation relationship between the two nodes.

I was somewhat surprised as I read your post, since you mention a "Treat translation nodes as a single node" setting which I can seem to find in any Nodequeue configuration form. I'am also using version 6.x-2.9, so can you tell me where can I find that setting?

Thanks in advance,
Rolando Isidoro

alanburke’s picture

Hi Ronald
That setting is right at the bottom of the settings page for the individual nodequeue.
[I went with a different solution in the end, but I might be back to this issue in the future]

rolando.isidoro’s picture

Hi Alan,

after writing my reply, I noticed on my site status report that in order for nodequeue to handle translations I needed to install the Translation helpers module and so I did.

The "Treat translation nodes as a single node" setting is now showing at the bottom of the create/edit nodequeue form, but after enabling it the result remains the same, I still have to manage translation nodes in the queues on my own.

Can you tell me which solution did you end up with?

Regards,
Rolando Isidoro

alanburke’s picture

Hi Rolando
We didn't use nodequeue at all in the end.
Built some extra views.
But we may have to revisit.

Naiya’s picture

have the same here! i have an option called "Add translations of content to the queue as a group" at the bottom of edit nodequeue but i cannot change it..

Naiya’s picture

i don't know why it is not editable while on another instance of drupal it's ok. but i cannot reach other nodes than in default language that way.. well, not yet i hope :)

jchatard’s picture

Hi all,

Same problem here.

Also tested with latest dev version.

Jérémy

yvmarques’s picture

Hello,

I've the same problem and I found why we don't have the nodes in another languages.

To get nodes from a nodequeue you need add relationship in the views if you've activated "Treat translation nodes as a single node" option you'll have only the source node in the nodequeue.

Until there it's normal, but the problem it's when you want show nodes from another language, because they aren't part of nodeque, I mean they aren't in nodequeue_nodes table, they're not selected by the relation.

I tried to find a solution with different configs, like Node translation : Sources and etc.. without success. I guess the only way how to fix it, is to add a possibility to tell nodequeue that the children nodes from source are also in nodequeue_nodes.

Regards,

yvmarques’s picture

Hi again,

I was starting to do a smartqueue module for languages, that can help us in this issue and finally somebody else already start to do it. You can find it there, I installed and try it's work fine for me :)

http://drupal.org/project/smartqueue_language

Regards,

-- Yvan

Fernando Vesga’s picture

hi, you should look at this http://drupal.org/node/433930#comment-2759852.
i was very helpful to me.

amateescu’s picture

Status: Active » Fixed
Issue tags: -translations

Marking as fixed based on #12 and until proven otherwise :)

Status: Fixed » Closed (fixed)

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

mattez’s picture

Version: 6.x-2.9 » 7.x-2.x-dev
Category: feature » support
Status: Closed (fixed) » Active

The Source Translation trick sort of worked for me too. But it shows only nodes which are already translated. Nodes without translation are not shown. I want simple thing: one multilingual limited (Queue size) nodequeue. So Internalization must be setup to "Treat translation nodes as a single node". And then display nodes in queue based on the current user language. It should not be dependent on whether the node is translated or not.

Example:

  1. I've put some nodes in English in my nodequeue.
  2. I setup the "Source Translation trick", and it returns nothing cause none of nodes have translation or better to say there is no "Source Translation" for nodes which is required ("Nodequeue: Queue" is required and got "realitionship" with "Content translation: Source translation").
  3. Then I translate one node to Spanish.
  4. When switching languages there is only one node (translated one) shown in my nodequeue.
  5. Then I translate one more node to Spanish. And there are show two nodes for English, two for Spanish.
  6. Same when I put untranslated node in Spanish to nodequeue. Until I translated it its not shown in nodequeue.
    I want to show all nodes in queue and than filter them via views lang filter Content translation: Language (= Current user's language).
    I have tried to use "Content translation: Translations" setup to show ALL translations.
    It really returns all nodes from my nodequeue, but setting up lang filter did nothing, still shows all translated nodes regardless of filter settings.
    What I'm missing?

    My setup:
    Drupal 7.0
    Internationalization 7.x-1.0-beta5
    Translation helpers 7.x-1.x-dev
    Nodequeue 7.x-2.0-alpha1

setvik’s picture

Here's what worked for me:

You'll need 3 relationships & some funky filtering.

Relationships

  • Add the Content Translation: Source translation relationship.
    • Uncheck "Require this relationship".
  • Add the Nodequeue: Queue relationship
    • Select "Source translation" in the "Relationship" dropdown
    • Give it an identifier of "queue translated".
    • Uncheck "Require this relationship".
  • Add the Nodequeue: Queue relationship.
    • Select "Do not use a relationship" in the "Relationship" dropdown
    • Give it an identifier of "queue untranslated".
    • Uncheck "Require this relationship".

Filtering

  • Add "Nodequeue: In queue" filter
    • Select "queue untranslated" in the "Relationship" dropdown
    • Select True for "In queue".
  • Add another "Nodequeue: In queue" filter
    • Select "queue translated" in the "Relationship" dropdown
    • Select True for "In queue".
  • Create a new filter group that "or"'s the 2 filters you just added together and then "and"s them with any other filters you have (e.g. the language filter).
    • HINT: In the actions dropdown next to "Filter criteria", select "and/or" to get to the filter group configuration screen
goofrider’s picture

I can follow #16 only up to the very last step. How do I create a filter group in Views 3?

setvik’s picture

Click the "and/or" option in the dropdown next to "Filter criteria" on the views configuration screen to create the filter group.

My screen looks like this:

screenshot

mattez’s picture

Stevik THANX a LOT!! It works!! Great!

Hint for others:
For correct SORTING set SORT CRITERIA to

(queue untranslated) Nodequeue: Position (asc)
(queue translated) Nodequeue: Position (asc)

Stevik THANX a LOT again!

pauleb’s picture

Thanks Stevik for the clear, structured instructions and mattez for the additional hint!

I managed to get it right at the second try. I misread your post as if the additional filters, where you used the language filter as example were optional and the selection would be done through the relationships.

So for the folks to come - make sure you also set the language filter:

Content translation: Language = current user's language

rafinskipg’s picture

Component: Code » Documentation
Status: Active » Closed (works as designed)

Just do this for seeing translated nodes based on currents user language.

Relationships

Add the Content Translation: Source translation relationship.
Uncheck "Require this relationship".
Add the Nodequeue: Queue relationship
Select "Source translation" in the "Relationship" dropdown
Uncheck "Require this relationship".

Filtering

Filter By users current language

With this and with #16 and #18 all is done,
I close the issue

dystopianblue’s picture

#16 + hint from #19 did the trick!

drupalninja99’s picture

#16 looks like it works for me

tinker’s picture

Version: 7.x-2.x-dev » 6.x-2.x-dev
Category: support » bug
Status: Closed (works as designed) » Needs review
FileSize
7.1 KB

I was not happy with the complexity of the workarounds to get proper results from multilingual nodes using 'Treat translation nodes as a single node' [i18n is TRUE]. I have created a patch that modifies the nodqueue view relationship handler to properly select translated versions of content. I do not think this is a 'support request' nor does the module 'work as designed'. I have therefor set this as a bug that needs review. This thread was originally a 6.x issue so I have switched it back.

After applying this patch all you have to do is create a view, add a nodequeue relationship [Queue (qid)], then add 'content negotiation' filter.

Upgrade notes:

  • Patch is for 6.x-2.x-dev
  • Flush caches after applying patch
  • Edit all views that use 'Treat translation nodes as a single node' queues. Other existing view are not affected.
  • You cannot mix queues that use i18n and those that don't. If you try to you will get an error and have to select only queues using i18n or only those that don't.

Changes made

This modifies the join statement ON condition. For queues that use i18n from (node.nid = nodequeue.nid) to (node.nid = nodequeue.nid OR node.tnid = nodequeue.nid) which selects all langauges of the source node.

Suggestion

I do not think that limiting results in the relationship is the Views way of doing things. Relations are meant to link content and not filter it. I suggest that a view filter that uses the relationship be used instead. If people agree I can modify this patch and create the filter. I kept it the way it was to reduce code change complexity and so that existing user's workflow would remain the same.

erikstraub’s picture

Forgive me if this is naive, but wouldn't this just be as simple as doing the following?


$result = db_query("SELECT GROUP_CONCAT(node.nid) as nids FROM node INNER JOIN nodequeue_nodes ON node.nid = nodequeue_nodes.nid AND nodequeue_nodes.qid = :qid WHERE (node.language = :language OR node.language = 'und') ORDER BY nodequeue_nodes.position ASC", array('qid' => 1, 'language' => $language->language));
  $banners = node_load_multiple(explode(',',$result->fetchObject()->nids));

* Note this is also selecting nodes with undefined language

tinker’s picture

@erikstraub, I think there is a difference on the join to nodequeue_nodes in your SQL. When I was reworking this I remember reworking the primary query to provide nid or tnid on the join and then pulling all the info from the join. I am traveling right now an cannot test. If you can then please report your findings. The language negotiation is handled by i18n module and cannot be hardcoded as it has multiple factors. If I remember correctly the nid/tnid table join influenced this.

tinker’s picture

@erikstraub, I was finally able to test and can confirm that your SQL does not return the correct results. If 'Treat translation nodes as a single node' is enabled then only the source 'nid' is stored in 'nodequeue_nodes'. The more complex join is required to get the source 'nid' or the translated 'nid' from 'node' table. The join is also required so that i18n can alter the SQL for language negotiation.

bryanhidalgo’s picture

#16 works like a charm! Thanks

letrotteur’s picture

Works great for me but only for the admin role? Anyone experienced something similar?

I mean #16 works great for the admins, but other roles only get translated nodes. Might be missing some permissions but just can't figure it out.

chousmith’s picture

just wanted to say that #16 steps worked like a champ for our site, Drupal 7.26 + Views 7.x-3.7 + Nodequeue 7.x-3.x-dev , with the particular Nodequeue itself set to "Treat translation nodes as a single node". yay

Soubi’s picture

Issue summary: View changes

I have the same problem that letrotteur describe in #29 (Drupal 7.28 + Views 7.x-3.8 + Nodequeue 7.x-2.0-beta1)

The method describe in #16 works only for the admins, not for anonymous user :(

pfrenssen’s picture

I can't get the ordering to work when using the approach suggested in #19. Not all nodes in my nodequeue are translated, so I'm displaying a mix of current language nodes and nodes in the default language. By ordering first on the current language and then on the default language all my current language nodes appear near the top of the queue.

pfrenssen’s picture

You can also achieve it by altering the Views query programmatically.

/**
 * Implements hook_views_query_alter().
 */
function mymodule_views_query_alter(&$view, &$query) {
  global $language;

  if ($view->name == 'my_view' && $view->current_display == 'my_display') {
    $nodequeue = nodequeue_load_queue_by_name('my_nodequeue');
    $subqueues = nodequeue_load_subqueues_by_queue($nodequeue->qid);
    $subqueue = reset($subqueues);

    // Compile our list of nodes. We need a list of nodes in the current
    // language, ordered by the position in the nodequeue. If the node is not
    // present in the current language the default (English) translation should
    // be used as a fallback.
    $nids = array();
    foreach (nodequeue_load_nodes($subqueue->sqid) as $node) {
      // If a translation exists in the current language then use it, otherwise
      // fall back to the default (English) translation.
      $nids[] = ($translations = translation_node_get_translations($node->nid)) && array_key_exists($language->language, $translations) ? $translations[$language->language]->nid : $node->nid;
    }

    // Add our list of nodes to the query.
    $query->add_where(0, 'node.nid', $nids, 'IN');

    // Add the sort order to the query. This is an arbitrary order which is done
    // with 'FIELD()' sorting in SQL. This sorting method is not supported by
    // the Views query builder API so we add it directly to the list of order by
    // clauses rather than using views_plugin_query_default::add_orderby().
    $node_order = implode(', ', $nids);
    $query->orderby[] = array(
      'field' => "FIELD(node.nid, $node_order)",
      'direction' => '',
    );
  }
}