Hi guys,
We have a website with three languages. One is English (left to right) and the others are right-to-left languages. Therefore when using Simplenews Scheduler to create a new edition based on dynamic view (using insert_view module to add a view in the original newsletter node), Drupal will generate view in the default language environment - English (en) and then Simplenews Scheduler saves it as a new edition. But the language of nodes in the view is right-to-left, the new edition could not display correctly, for example the text direction, links which should be based are corresponding language instead of links in English format
Therefore, in the node saving part, when node is loaded, it should check and transform language and then to build node content (apply view filter)
function _simplenews_scheduler_new_edition($nid) {
$node = node_load($nid);
if (module_exists('upload')) {
$files = upload_load($node);
}
$node = node_build_content($node, FALSE, FALSE);
Hence I add some language detection part:
function _simplenews_scheduler_new_edition($nid) {
global $language;
$node = node_load($nid);
if (!empty($node->language) && $language->language != $node->language) {
$languages = language_list('enabled');
$languages = $languages[1];
if ($languages[$node->language]) {
$language = $languages[$node->language];
}
}
if (module_exists('upload')) {
$files = upload_load($node);
}
$node = node_build_content($node, FALSE, FALSE);
By the way I also remove the line
$content = drupal_render($node->content);
Because it looks isolated.
Please reviewed my patch and hope it can be adopted.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | simplenews_scheduler.support_multilanguage2.patch | 1.53 KB | eric.chenchao |
| simplenews_scheduler.support_multilanguage.patch | 1.1 KB | eric.chenchao |
Comments
Comment #1
sgabe commentedI think it's okay to modify the language to build the node content, but after that shouldn't we set it back to the original value?
Comment #2
eric.chenchao commentedHi Sgabe,
Thanks for quick response. Yes you are right we need to transform language back once new edition node is created.
Comment #3
dgtlmoon commentedHave you tried the 2.x branch?