'field_tags' => array(
  'und' => array(
    0 => array(
      'tid' => '1',
    ),
  ),
),

My terms are exported by uuid_term and it works well. However when importing into another server, [tid] would not remain the same of course. But my nodes are referred to term's [tid] not [uuid]... which makes it a mess now - -

Is that possible that make exported nodes referred to [term-uuid]?

Thanks!

Comments

zhangx1a0’s picture

Assigned: Unassigned » zhangx1a0
Status: Active » Needs review

Never mind. After reading the codes I think it can be done by implementing hooks provided by uuid_node. I am pasting my codes here in case anyone would need:

/**
 * Implementation of hook_uuid_node_features_export_render_alter(&$export, $node, $module);
 * Export UUID of terms.
 */
function misc_uuid_node_features_export_render_alter(&$export, $node, $module) {
    static $uuids = array();

    $fields_info = field_info_instances('node', $node->type);
    foreach ($fields_info as $field_name => $value) {
        $field_info = field_info_field($field_name);
        $type = $field_info['type'];
        if ($type == 'taxonomy_term_reference') {
            if (!empty($node->$field_name)) {
                if (!isset($_uuids[$node->{$field_name}[LANGUAGE_NONE][0]['tid']])) {
                    $uuids += entity_get_uuid_by_id('taxonomy_term', array($node->{$field_name}[LANGUAGE_NONE][0]['tid']));
                }   

                // $export = $node
                $export->{$field_name}[LANGUAGE_NONE][0]['uuid'] = $uuids[$node->{$field_name}[LANGUAGE_NONE][0]['tid']];
            }   
        }   
    }   
}

/**
 * Implementation of hook_uuid_node_features_rebuild_alter(&node, $module);
 * Update term's tid according to UUID.
 */
function misc_uuid_node_features_rebuild_alter(&$node, $module) {
    static $tids = array();

    $fields_info = field_info_instances('node', $node->type);
    foreach ($fields_info as $field_name => $value) {
        $field_info = field_info_field($field_name);
        $type = $field_info['type'];
        if ($type == 'taxonomy_term_reference') {
            if (!empty($node->$field_name)) {
                if (!isset($tids[$node->{$field_name}[LANGUAGE_NONE][0]['uuid']])) {
                    $tids += entity_get_id_by_uuid('taxonomy_term', array($node->{$field_name}[LANGUAGE_NONE][0]['uuid']));
                }   

                if ($tids[$node->{$field_name}[LANGUAGE_NONE][0]['uuid']] != $node->{$field_name}[LANGUAGE_NONE][0]['tid']) {
                    $node->{$field_name}[LANGUAGE_NONE][0]['tid'] = $tids[$node->{$field_name}[LANGUAGE_NONE][0]['uuid']];
                }   
            }   
        }   
    }   
}
leeomara’s picture

busla’s picture

I think this issue is critical. Terms are used as a relationship method to other entities but the module doesn´t move this relationship to the feature since nodes and terms are related by the tid. Am I maybe misunderstanding the purpose of the module?

Is it only to be used to preserve the term name and hierarchy but not the relationship to the nodes it belongs to?

saltednut’s picture

Priority: Major » Critical
Status: Needs review » Needs work

Agreed - its not full UUID integration if we don't support this. Marking as critical.

@zhangx1a0 can you provide a patch for the solution in #1?

saltednut’s picture

Category: feature » bug
hswong3i’s picture

I will try to roll a patch for #1 later ;-)

hswong3i’s picture

Assigned: zhangx1a0 » hswong3i
Status: Needs work » Needs review
StatusFileSize
new3.22 KB

Most likely idea coming from #1, but revamp from hook alter to default functionality in uuid_node.features.inc, also handle protential i18n and multiple terms per field.

Patch via GIT branch 7.x-1.x and confirm as functioning.

jeqq’s picture

saltednut’s picture

Issue summary: View changes

In an effort to get a bunch of these outstanding patches that people are using into one, this issue is being closed.

See: #2149949: Multiple Patches need to be committed to UUID Features and have been rolled into one.

saltednut’s picture

Status: Needs review » Closed (duplicate)