Drupal db_insert('node') 提升到首页等于 1 不工作
Drupal db_insert('node') promote to front page equel to 1 not working
我正在使用以下代码提升到首页,但它不起作用。它仅在节点 table 中插入条目。我需要在另一个 table 中插入条目来推广它。
节点 table 在 table 中显示 promote=1
值,但问题是在通过 drupal 管理和编辑文章检查它时,它没有显示选中的复选框或没有显示在前面页。
$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 不会显示在首页。所有变量都工作正常,查询也正常工作。
您是否尝试过使用本机 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);
我正在使用以下代码提升到首页,但它不起作用。它仅在节点 table 中插入条目。我需要在另一个 table 中插入条目来推广它。
节点 table 在 table 中显示 promote=1
值,但问题是在通过 drupal 管理和编辑文章检查它时,它没有显示选中的复选框或没有显示在前面页。
$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 不会显示在首页。所有变量都工作正常,查询也正常工作。
您是否尝试过使用本机 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);