drupal - 如何以编程方式创建论坛主题?

标签 drupal drupal-6 forum drupal-forms

我刚刚了解了如何使用以下链接以编程方式创建论坛和容器

http://www.unibia.com/unibianet/drupal/how-create-drupal-forums-and-containers-programmatically

但是从来没有看到任何以编程方式创建论坛主题的帖子(谷歌),无论我应该使用 node_save() 还是任何替代方法。

请帮帮我,

谢谢, 埃德文

最佳答案

以编程方式创建新节点的快速、安全和简单的方法是使用 node_save() :

<?php
  // Construct the new node object.
  $node = new stdClass();

  // Set the values for the node
  $node->title = "My new forum topic";
  $node->body = "The body of my forum topic.\n\nAdditional Information";
  $node->type = 'forum';   // Your specified content type
  $node->created = time();
  $node->changed = $node->created;
  $node->status = 1;       // To have published, else use 0
  $node->promote = 1;      // If you want promoted to front page, else use 0
  $node->sticky = 0;
  $node->format = 1;       // Filtered HTML
  $node->uid = 1;          // UID of content owner
  $node->language = 'en';

  // If known, the taxonomy TID values can be added as an array.
  $node->taxonomy = array(2,3,1,);

  node_save($node);
?>

关于drupal - 如何以编程方式创建论坛主题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5321632/

相关文章:

Drupal 公开 View 过滤器自定义日期

java - 寻找易于与现有用户表集成的基于 Java 的论坛引擎

php - 安全地将数据插入 MySQL 表并打印

javascript - 在 Drupal 的 CKEditor 4 中添加链接属性

css - 提交按钮顶部的图像图标

drupal - 以编程方式更新时配置文件 2 出错

unit-testing - 使用 DrupalUnitTestCase 对 Drupal 进行单元测试在数据库设置上失败

mysqld --defaults-file 和 tmpdir 问题

德鲁帕尔 6 : redirect admin url for custom user role

php - 在自定义编码论坛的正确标题下显示类别