Netzflut

Webdesign, Webentwicklung, Drupal & Zeuchs

Migrate/Field Collection

Inhaltsverzeichniss

    Wozu Migrate? Migrate ist ein Hilfsmodul mit dem man 3rd party Daten in Drupal migrieren kann. ACHTUNG man muss hier programmieren.

    Dokumentation

    http://drupal.org/node/415260

    Artikel

    http://www.davidreig.com/article/drupal-migrate-module-tutorial-migrating-multilingual-content
    http://www.gizra.com/content/data-migration-part-1
    http://www.slideshare.net/SrijanOne/typo3-to-drupalmigratemodule
    http://www.gizra.com/content/data-migration-part-2

    Video

    http://denver2012.drupal.org/program/sessions/getting-it-drupal-migrate

    Entity relation migration

    http://janezurevc.name/relation-migrate-integration-and-reference-upgrade-path

    Modul als Beispiel
    http://drupal.org/project/entityreference_migration
    http://drupal.org/node/1536914

    Field Collection

    http://pingv.com/blog/drupal-migration-tips-handlers-field-collections-process-preprocess
    http://nikro.me/articles/professional/drupal-field-collections

    WARNUNG

    Eine Fieldcollection mit Entityreferencen zu migrieren geht nicht wirklich und wenn nur mit workarounds usw. Ich hab jetzt bald 10 Stunden in den Sand gesetzt und mach das nun manuell d.h Node anlegen per code und füllen...

    Field Collection programmatisch anlegen

    Weg 1

    <?php
    // Create node
    $node = new stdClass();
    $node->type = 'article';
    node_object_prepare($node);
    $node->title = 'Testing Article Creation';
    $node->language = LANGUAGE_NONE;
    $node->status = 1;
    $node->uid = 1;
    node_save($node);
     
    // Create and save field collection for node
    $field_collection_item = entity_create('field_collection_item', array('field_name' => 'bir_collection'));
    $field_collection_item->setHostEntity('node', $node);
    $field_collection_item->bir_collection_node[LANGUAGE_NONE][]['nid'] = 99999;
    $field_collection_item->save();
    ?>

    Weg 2

    http://drupal.org/node/1477186

    <?php
    function foo_log_activity($node, $message, $uid = NULL) {
      // Load the controller class file.
      module_load_include('inc', 'entity', 'includes/entity.controller');
     
      // Use the currently logged in user if a $uid argument is not defined.
      global $user;
      if (empty($uid)) {
        $uid = $user->uid;
      }
     
      // Grab the current time in the format required by our date field. We need
      // gmdate() here to get a time in UTC which is how everything is stored
      // internally.
      $now = gmdate('Y-m-d H:i:s');
     
      // Setup the values in the structure expected by the field_collection entity.
      $values = array(
        'field_name' => 'field_activity_log',
        'field_activity_log_date' => array(
          LANGUAGE_NONE => array(array('value' => $now)),
        ),
        'field_activity_log_message' => array(
          LANGUAGE_NONE => array(array('value' => $message)),
        ),
        'field_activity_log_user' => array(
          LANGUAGE_NONE => array(array('uid' => $uid)),
        ),
      );
      $entity = entity_create('field_collection_item', $values);
     
      // Attach the field_collection entity to the application node. This has to
      // happen separately so that it actually works -- you can't just specify
      // this via the $values array.
      $entity->setHostEntity('node', $node);
     
      // Save the entity. Since it's attached to the right application node, this
      // will both create the field_collection entity and update the application
      // node to point to the new field_activity_log record.
      $entity->save();
    }
    ?>

    Entity API

    http://drupal.org/node/1842304

    http://rajanmayekar.com/blog/programmatically-creating-deleting-modifying-field-collection-item-node | SUPER ARTIKEL

    Drupal: