A certain module (tinyMCE_NODE_Picker) is using a predefined view to show available nodes to insert into the post as link. After enhancing the view with a language filter ("Current language or none") a strange behaviour occurs. If this view is called through a page, this filter works correctly, and produces a correct QUERY for the selected language (i.e. Slovak, 'SK'):
[CODE]SELECT node.nid AS nid, node.title AS node_title, node.language AS node_language, node.type AS node_type, node.status AS node_status FROM drupal6_node node WHERE (node.type in ('cck_authority')) AND (node.language in ('sk', '')) ORDER BY node_title ASC LIMIT 0, 10[/CODE]
However, if this views is called from the module using [B]views_embed_view('view_name', 'default');[/B], then the generated query does not reflect the currently set language (SK), and ends up using the following query:
SELECT node.nid AS nid, node.title AS node_title, node.language AS node_language, node.type AS node_type, node.status AS node_status FROM drupal6_node node WHERE (node.type in ('cck_authority')) AND (node.language in ('en', '')) ORDER BY node_title ASC LIMIT 0, 10
This query is the same as if it was used while the language was English, which is definitely not the case.
I understand that the substitution mechanism should replace '***CURRENT_LANGUAGE***' with $language->language, but for views_embed_view this for whatever reason, does not work. Any help is appreciated!
It is important to point out that caching for this view is completely disabled.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | Clipboard-1.jpg | 73.54 KB | notabenem |
| #5 | Clipboard-2.jpg | 66.3 KB | notabenem |
Comments
Comment #1
dawehnerWhat happens if the module executes drupal_init_language() before calling the view?
Comment #2
notabenem commentedHi, thank you for the suggestion, but it does not help. It seems it always uses the default language, whatever it is set to (tried changing the default language from en to sk and now I always get sk results, even if lang is set to en).
Comment #3
dawehnerIs sk the content language or the "global" language which you can set in the user profile of the current user.
Comment #4
notabenem commenteden is the "global" language. The content language is undefined for new contents, but even if defined (en or sk) it does not seem to have an effect.
Comment #5
notabenem commentedFurther refining the issue. So Clipboard-1.jpg shows correct user locale ('en') when the popup appears. However, I want to refine the search using the exposed filters, so I set some criteria. After the refresh (Clipboard-2.jpg), the message says the language is 'sk', which is incorrect. I did not change it to 'sk'.
It seems, that it is enough just to hit the "apply" in the popup window, and the $language->language variable forgets its value ('en') and changes to the default language, which in this case was 'sk'.
Important: before taking these two screenshosts, I changed the Default Language to be 'sk'. At the time of the original post, it was "en".
Comment #6
notabenem commentedAnother update: the issue is present even if it isn't a popup window.
It can be reproduced just by creating a static page with embedded PHP and putting inside the following:
Because of this I don't think this issue is related to tinyMCE. More likely views or core.
Comment #7
notabenem commentedComment #8
notabenem commentedBUMP - Please hint at further steps where to route or how to resolve.
Comment #9
dawehnerDid you tryed suggestion from http://drupal.org/node/875574#comment-3296238 ?
Comment #10
notabenem commentedYes, I tried that. As it can be seen from comment #2, it did not help and it made the whole thing even worse (I don't recall what was it exactly, but i had to remove it). I repeat, it did not help. Are you able to recreate the issue?
Comment #11
notabenem commentedAny ideas on this? I'd be glad to test different setups.
Comment #12
iamjon commentedThe module that you are trying to fix has this on it's page
"This module will de discontinued and replaced with Node Picker as soon as a stable release is available."
I suggest you try with the Node Picker module and see if you are still having problems.
If yes, try file an issue with them first.
Good luck
marking as won't fix.
Comment #13
notabenem commentedDear iamjon,
The module I am trying to fix here is not nodepicker, but whatever that is causing that $language->language gets reset to it's default value whenever I hit the "Apply" button on a views exposed filter form. For that reason, I thought starting with views would be a good start.
Are you not able to reproduce this bug?