Creating drupal pages (nodes) automatically from other (xml) content

Currently, I have a data source from the client in the form of XML, this XML has content for all the pages that will be created on the website. Now after parsing and preparing all this content, does anyone know how we can (using) PHP automate the creation of drupal node (including all related fields for these node ie CCK fields, paths).

Ideally, a function with which we can send all the content and create the nodes. Now I do not mind putting it directly in db, but I'm not quite sure that the db tables are updated (since the drupal setting has gazillion tables).

I searched through google and drupal docs, but I can not find something for this (which I suggested is a simple and frequently used function of web developers on drupal ..)

Your input will be much appreciated!

Thanks in advance,

Shadi

+3
source share
3 answers

You can use the Drupal function node_savesomething like this:

require 'includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$node = new stdClass();

$node->title = "My imported node";
$node->body = "The body of my imported node.";
$node->type = 'story'; 
$node->created = time();
$node->changed = $node->created;
$node->status = 1;
$node->promote = 1;
$node->sticky = 0;
$node->format = 1;
$node->uid = 1;

node_save($node);

For more information, see this article on the Acquia website (including CCK fields if you use pathauto, which should create paths on node_save): http://acquia.com/blog/migrating-drupal-way-part-i-creating-node

+5
source

node_save() . cck, , . , nodetype , , .

+1

node_save works for cck if you set the type and format fields in the array structure correctly.

0
source

Source: https://habr.com/ru/post/1712335/


All Articles