Created
July 4, 2013 15:34
-
-
Save typhonius/5928664 to your computer and use it in GitHub Desktop.
node export i18n for PHP < 5.3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file Node Export i18n module | |
*/ | |
// Ensure this node type has multilingual support | |
/** | |
* Implements hook_node_export_alter | |
* | |
* The point of this is to alter the tnid of the output to be that of the original node | |
*/ | |
function node_export_i18n_node_export_alter(&$nodes, $format) { | |
foreach ($nodes as $index) { | |
$index->tnid = $index->tnid ? $index->tnid : $index->nid; | |
} | |
} | |
/** | |
* Implements hook_node_export_after_import_alter | |
* | |
* Exists to update tnids in the {node} table to link translated nodes | |
*/ | |
function node_export_i18n_node_export_after_import_alter(&$nodes, $format, $save) { | |
// load nodes | |
foreach ($nodes as $node) { | |
// check translation status of node type (drupal static) | |
if ($node->tnid) { | |
db_update('node') | |
->fields(array( | |
'tnid' => $node->tnid, | |
)) | |
->condition('nid', $node->tnid) | |
->execute(); | |
} | |
} | |
// no example code | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment