简体   繁体   English

使用不带CCK的钩子在故事内容类型中添加额外的字段

[英]Add extra field in story content type using hook without CCK

I want to add extra field in story content type using hook, I don't want to use CCK, because am trying something different. 我想使用挂钩在故事内容类型中添加额外的字段,我不想使用CCK,因为我正在尝试其他方法。

Please tell some suggestion with hook method. 请用钩子方法告诉一些建议。

If you do not use CCK, you will have to create your database table and code to add the form field, validate the form field, capture the data and save it in your field. 如果不使用CCK,则必须创建数据库表和代码以添加表单字段,验证表单字段,捕获数据并将其保存在您的字段中。 I know cck can be a monster, but it does all this for you. 我知道cck可以成为怪物,但是它可以为您做所有这一切。 I'd be happy to give you more info on all of this, but it is quite lengthy 我很乐意为您提供所有这些方面的更多信息,但这很长

There are lots of reasons that you may want to do this without CCK or Fields, and the best example is found at the node_example module in the examples project which can be found at: http://drupalcode.org/project/examples.git/tree/refs/heads/6.x-1.x:/node_example . 没有CCK或Fields可能有很多原因,最好的例子是在示例项目的node_example模块中找到的,该模块位于: http ://drupalcode.org/project/examples.git /tree/refs/heads/6.x-1.x:/node_example You can also view the documentation on api.drupal.org . 您也可以在api.drupal.org上查看文档。

The short version is that you're going to have to define your own node type using hook_node_info() and then define all the hooks for _load(), _insert(), _update(), _delete(), _access(), _validate(), and _view() in addition to defining your schema in your hook_schema and managing your tables on your own. 简短的版本是,您将必须使用hook_node_info()定义自己的节点类型,然后定义_load(),_ insert(),_ update(),_ delete(),_ access(),_ validate()的所有钩子)和_view(),以及在hook_schema中定义架构并自行管理表格。

Sadly there is no good example for Drupal 7 as the node_example module for 7 was converted to use fields instead of the hooks listed above, which are still fully documented on api.drupal.org (they do now typically act on an array of nodes instead of a single node, but are otherwise identical). 遗憾的是,对于Drupal 7并没有很好的示例,因为7的node_example模块已转换为使用字段而不是上面列出的钩子,这些钩子仍在api.drupal.org上有完整记录(它们现在通常对节点数组起作用)一个节点,但在其他方面相同)。

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

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