简体   繁体   English

如何通过 PHP 或 MySQL 在 Drupal 7 上发布博客模块?

[英]How to post to blog module on Drupal 7 by PHP or MySQL?

I have a problem with posting to Drupal 7 core blog module.我在发布到 Drupal 7 核心博客模块时遇到问题。

Can you give me a simple example (PHP code or MySQL query) how to add a blog post where:你能给我一个简单的例子(PHP 代码或 MySQL 查询)如何添加博客文章,其中:

Title="Blog post title"
Post content="Content".

I need a PHP or MySQL example.我需要一个 PHP 或 MySQL 示例。 I don't want to post on home page.我不想在主页上发帖。

create it programatically by writing this code in your module file通过在模块文件中编写此代码以编程方式创建它

 $text_body = 'Your node body text'; $node = new stdClass(); // Create a new node object $node->type = 'blog'; // Content type $node->language = LANGUAGE_NONE; // Or eg 'en' if locale is enabled node_object_prepare($node); //Set some default values $node->title = 'Your node title'; $node->body[$node->language][0]['value'] = $text_body; $node->body[$node->language][0]['summary'] = text_summary($text_body); $node->body[$node->language][0]['format'] = 'full_html'; $node->status = 1; // (1 or 0): published or unpublished $node->promote = 0; // (1 or 0): promoted to front page or not $node->sticky = 0; // (1 or 0): sticky at top of lists or not $node->comment = 1; // 2 = comments open, 1 = comments closed, 0 = comments hidden // Add author of the node $node->uid = 1; // Set created date $node->date = 'complaint_post_date'; $node->created = strtotime('complaint_post_date'); $path = 'content/blog-' . date('YmdHis'); $node->path = array('alias' => $path); // Save the node node_save($node);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM