[英]Drupal 7 Does “New Node Creation” initiate/prepare the Fields for different Content Types?
In Drupal 7, i need to Programmatically
create the Nodes. 在Drupal 7中,我需要以Programmatically
创建节点。 As usual, there are Different Fields
set for Different Content Types
. 与往常一样,为Different Content Types
设置了Different Content Types
Different Fields
。
For very simple example: 对于非常简单的示例:
Content Type: "car"
Fields: "Model", "Engine", "GearType"
Content Type: "article"
Fields: "Title", "Author", "Media"
What i want to be confirmed here is, while
i am creating a new node, for eg by using: 我想在这里确认的是, while
我创建一个新节点时,例如通过使用:
$node = new stdClass();
$node->type = "car";
Then.. 然后..
$node
has been initiated/loaded with its related/corresponded fields, already before get saved? 是(当前正在创建)新的$node
已在保存之前启动/加载了相关/对应的字段吗? node_save($node)
(without filling any other related fields) will that node
be still having (following) its proper Content Type structure? 更明确地说,如果我只是突然保存一个节点node_save($node)
(不填充任何其他相关字段),那么该node
是否仍将(遵循)其正确的Content Type结构? I think this is what your looking for: 我认为这是您要寻找的:
$node = new stdClass();
$node->type = 'article';
node_object_prepare($node);
There is a nice blog post about this here: http://www.group42.ca/creating_and_updating_nodes_programmatically_in_drupal_7 这里有一篇很好的博客文章: http : //www.group42.ca/creating_and_updating_nodes_programmatically_in_drupal_7
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.