function _site_disclaimer_nid_translated in Site Disclaimer 7
Same name and namespace in other branches
- 6 site_disclaimer.module \_site_disclaimer_nid_translated()
Get translation of a node for the current language.
2 calls to _site_disclaimer_nid_translated()
- site_disclaimer_form_user_register_form_alter in ./
site_disclaimer.module - Implements hook_form_form_id_alter().
- _site_disclaimer_enabled in ./
site_disclaimer.module - Determine if site_disclaimer is enabled.
File
- ./
site_disclaimer.module, line 362 - This module adds Site Disclaimer to the registration page.
Code
function _site_disclaimer_nid_translated($nid, $langcode = NULL) {
if ($nid != '' && module_exists('translation')) {
if (empty($langcode)) {
global $language;
$langcode = $language->language;
}
// translation_node_get_translations() returns empty set for $nid, but works ok ith $node->tnid. Go figure.
$node = node_load($nid);
$translations = translation_node_get_translations($node->tnid);
if (!empty($translations[$langcode])) {
$nid = $translations[$langcode]->nid;
}
}
return $nid;
}