如何以编程方式创建论坛主题? [英] How to create a forum topic programmatically?

查看:116
本文介绍了如何以编程方式创建论坛主题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I just gone through how to create forums and containers programmatically with the below link

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

但是从来没有看到任何发表(谷歌)的机会创建论坛主题,无论我是否应该使用node_save()或任何替代方案。

But never see any post(google) which create forum topic pro-grammatically, whether i should go with node_save() or any alternative.

请帮助我,

谢谢,
Edvin

Thanks, Edvin

推荐答案

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

A quick, safe and easy way to create new nodes programmatically is to use 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);
?>

这篇关于如何以编程方式创建论坛主题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆