添加Drupal节点记录的配方 [英] Recipe for adding Drupal node records
问题描述
我正在寻找添加Drupal节点记录的方法。
我已经确定了三个表。
I am looking for a recipe for adding Drupal node records. I have identified three tables.
node_revisions
nid=249 - vid + 1?
vid=248 - auto-increment
node:
nid=250 - vid + 1?
vid=249 - auto-increment
content_type_my_content
vid=248 - from node_revisions table?
nid=249 - from node table?
我在正确的轨道上吗?
是否有一些帮助函数?
Am I on right track? Is there some helper functions for this?
推荐答案
如果您正在编程创建节点,请使用Drupal API 。
If you are looking to programatically create nodes, use the Drupal API.
首先创建一个$ node对象。填写标题,类型,状态,正文,加上任何CCK字段。最后,调用node_save($ node);.
Start by creating a $node object. Fill in title, type, status, body, plus any CCK fields. At the end, call node_save($node);.
node_save将保存您的节点对象并进行必要的数据库工作。
node_save will save your node object and do the necessary database work.
请查看:
http://api.drupal。 org / api / function / node_save / 6
http://mediumexposure.com/how-build-node-drupal-programmatically/
最简单的方法看看每种类型的内容类型是如何创建一个节点(例如,页面),然后使用var_dump()来查看节点的内容。这将显示您需要在节点对象创建脚本中使用的每个字段。
The easiest way to see what each type of content type has as fields is to create a node (for example, Page), then use var_dump() to see the node's contents. That will show you every field you will need to use in your node object creation script.
有些人会说你应该创建一个表单数组,并调用drupal_execute()所以验证在保存到数据库之前执行。无论哪种方式都可以。
Some folks will say you should create a form array, and call drupal_execute() on it so validation is performed before it's saved to the database. Either way is fine.
这篇关于添加Drupal节点记录的配方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!