gpt4 book ai didi

mysql - Drupal db_insert ('node' ) 提升到首页等于 1 不起作用

转载 作者:行者123 更新时间:2023-11-29 21:48:43 27 4
gpt4 key购买 nike

我正在使用以下代码来提升到首页,但它不起作用。它仅在节点表中插入条目。我需要将条目插入到另一个表中以提升它。

节点表在表中显示 promote=1 值,但问题是在通过 drupal admin 检查它并编辑文章时,它没有显示选中的复选框或没有显示在首页。

$insert = db_insert('node')
->fields(array(
'title' => $rtitle,
//'vid' => '',
'type' => 'article',
'language' => 'und',
'uid' => '1',
'created' => $pubdate,
//'comment' => '',
'promote' => '1',
//'sticky' => '',
//'tnid' => '',
'status' => '1',
))
->execute();

因此,promote=1 不会显示在首页。所有变量也都工作正常,查询也正常工作。

enter image description here

最佳答案

您是否尝试过使用 native Drupal 方法在代码中创建节点?

  global $user;

$node = new stdClass();
$node->title = "My Cool Article";
$node->type = "article";
node_object_prepare($node);
$node->language = LANGUAGE_NONE;
$node->uid = $user->uid;
$node->status = 1;
$node->promote = 1;
$node->comment = 0;

node_save($node);

关于mysql - Drupal db_insert ('node' ) 提升到首页等于 1 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33870694/

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