douzheng5717 2009-07-10 20:48
浏览 40
已采纳

从其他(xml)内容自动创建drupal页面(节点)

I currently have a datasource from a client in the form of XML, this XML has content for all the pages that the website we're making will contain. Now after parsing and preparing all this content, does anyone know how we can then (using) PHP automate the creation of a drupal node (including all related fields for that node i.e. CCK fields, paths).

Ideally a function we can send all the content to and the nodes get created. Now i don't mind putting it straight into the db, but i'm not quite sure what db tables get updated (as the drupal setup has a gazillion tables).

I've searched through google and the drupal docs, but i can't really find something for this (Which i assumed would be a simple and often used function by web developers on drupal..)

Your input will be very much appreciated!

Thanks in advance,

Shadi

  • 写回答

3条回答 默认 最新

  • duan2891 2009-07-10 22:57
    关注

    You can use Drupal's node_save function something 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);
    

    See this article on the Acquia site for more (including CCK fields, if you're using pathauto that should create paths on node_save): http://acquia.com/blog/migrating-drupal-way-part-i-creating-node

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因