// and at least an element /[root]/title.
echo "a";
include 'staff2011a.php';
$xml = new SimpleXMLElement($xmlstr);
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT.'/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// Import node functions.
module_load_include('inc', 'node', 'node.pages');
echo "1";
global $user; //get current logged in user
echo "2";
/* For each
foreach ($xml->staff as $arecord) {
echo $arecord->surname, ' played by ', $arecord->surname, PHP_EOL, "
";
$new_node = new stdClass();
$new_node->type = 'staff';
$new_node->uid = $user->uid; //you can specify some other userID here if you want
$new_node->name = $user->name;
$new_node->title = $arecord->first_name.' '.$arecord->surname;
$new_node->body = '';
$new_node->status = 1; // published
$new_node->field_extension[0]['value'] = $arecord->extension_number;
$new_node->field_mobile[0]['value'] = $arecord->mobile;
$new_node->field_phone[0]['value'] = $arecord->phone_number;
$new_node->field_email[0]['value'] = $arecord->email;
$new_node->field_position[0]['value'] = $arecord->position;
$new_node->field_fax[0]['value'] = $arecord->fax_number;
node_save($new_node);
echo "3";
} // end foreach
echo "b";
echo "4";
?>
No comments:
Post a Comment