function translation_node_get_translations
7.x translation.module | translation_node_get_translations($tnid) |
6.x translation.module | translation_node_get_translations($tnid) |
Gets all nodes in a given translation set.
Parameters
$tnid: The translation source nid of the translation set, the identifier of the node used to derive all translations in the set.
Return value
Array of partial node objects (nid, title, language) representing all nodes in the translation set, in effect all translations of node $tnid, including node $tnid itself. Because these are partial nodes, you need to node_load() the full node, if you need more properties. The array is indexed by language code.
7 calls to translation_node_get_translations()
- translation_form_node_form_alter in drupal-7.x/
modules/ translation/ translation.module - Implements hook_form_BASE_FORM_ID_alter() for node_form().
- translation_language_switch_links_alter in drupal-7.x/
modules/ translation/ translation.module - Implements hook_language_switch_links_alter().
- translation_node_overview in drupal-7.x/
modules/ translation/ translation.pages.inc - Page callback: Displays a list of a node's translations.
- translation_node_prepare in drupal-7.x/
modules/ translation/ translation.module - Implements hook_node_prepare().
- translation_node_validate in drupal-7.x/
modules/ translation/ translation.module - Implements hook_node_validate().
File
- drupal-7.x/
modules/ translation/ translation.module, line 461 - Manages content translations.
Code
function translation_node_get_translations($tnid) {
if (is_numeric($tnid) && $tnid) {
$translations = &drupal_static(__FUNCTION__, array());
if (!isset($translations[$tnid])) {
$translations[$tnid] = array();
$result = db_select('node', 'n')
->fields('n', array('nid', 'type', 'uid', 'status', 'title', 'language'))
->condition('n.tnid', $tnid)
->addTag('node_access')
->execute();
foreach ($result as $node) {
$langcode = entity_language('node', $node);
$translations[$tnid][$langcode] = $node;
}
}
return $translations[$tnid];
}
}