translation_node_get_translations

Versions
6 – 7
translation_node_get_translations($tnid)

Get all nodes in a translation set, represented by $tnid.

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.

▾ 6 functions call translation_node_get_translations()

translation_form_alter in modules/translation/translation.module
Implement hook_form_alter().
translation_node_overview in modules/translation/translation.pages.inc
Overview page for a node's translations.
translation_node_prepare in modules/translation/translation.module
Implement hook_node_prepare().
translation_node_validate in modules/translation/translation.module
Implement hook_node_validate().
translation_node_view in modules/translation/translation.module
Implement hook_node_view().
translation_path_get_translations in modules/translation/translation.module
Return paths of all translations of a node, based on its Drupal path.

Code

modules/translation/translation.module, line 351

<?php
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', 'title', 'language'))
        ->condition('n.tnid', $tnid)
        ->addTag('node_access')
        ->execute();

      foreach ($result as $node) {
        $translations[$tnid][$node->language] = $node;
      }
    }
    return $translations[$tnid];
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.