Last updated October 21, 2011. Created by mikeryan on December 24, 2010.
Edited by drewish, geerlingguy, chrisnovak. Log in to edit this page.
Here is a cookbook of random tips and ideas for specialized applications - feel free to add your own Migrate V2 tricks!
Modifying node body during migration
If you need to modify data in the node body during the migration process, you can use the prepareRow($row) hook. The following example displays how to call the user defined method "convertWiki2Html" which converts the node body from wiki markup to HTML:
<?php
// manipulate the source rows
public function prepareRow($current_row) {
$current_row->body = $this->convertWiki2Html($current_row->body_text,$current_row->page_title);
}
public function convertWiki2Html(&$body,&$title){
// convert $body from mediawiki to HTML here...
}
?>Importing Scheduled Content
If you need to import content that's unpublished, but scheduled for future publication, you can do so by setting a node's 'publish_on' property in your Migration class's prepare() method implementation. For example:
<?php
// In construct(), you have a row that has a published status of 0:
public function __construct() {
$this->addFieldMapping('status', 'status');
}
// In prepare(), you can set the timestamp for the time the node should
// be published (requires scheduler.module).
public function prepare($node, stdClass $row) {
if ($node->status == 0 && $row->status == 0 && $row->publish_time >= time()) {
$node->publish_on = $row->publish_time;
}
}
?>