gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 10:10:47 24 4
gpt4 key购买 nike

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

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com