Drupal 以编程方式删除节点类型和/或 cck 字段

发布于 2024-12-14 05:20:19 字数 311 浏览 6 评论 0原文

我的自定义模块创建一个带有一些 CCK 字段的节点类型。

当用户卸载时,我需要删除 CCK 字段,以便旧的 CCK 出现不会干扰重新安装模块时要创建的新 CCK 字段。

我正在尝试以下代码:

function mymodule_uninstall(){
   content_field_instance_delete('field_ccktest', 'my-node-type', FALSE);    
}

但是 content_field_instance_delete 锥体返回一个无法识别的函数。

My custom module creates a node type with a few CCK fields.

When the users un-installs, I need the CCK fields to be deleted so the old CCK occurances don't interfere with the new ones to be created should the module be re-installed.

I am trying the following code:

function mymodule_uninstall(){
   content_field_instance_delete('field_ccktest', 'my-node-type', FALSE);    
}

But the content_field_instance_delete cones back with a function not recognized.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

追我者格杀勿论 2024-12-21 05:20:19

CCK 的 CRUD 函数位于默认情况下不包含在 Drupal 引导程序中的文件中,您只需将其包含在函数中即可:

function mymodule_uninstall(){
  module_load_include('inc', 'content', 'includes/content.crud');
  content_field_instance_delete('field_ccktest', 'my-node-type', FALSE);    
}

CCK's CRUD functions live in a file that isn't included by default in the Drupal bootstrap, you just need to include it in your function:

function mymodule_uninstall(){
  module_load_include('inc', 'content', 'includes/content.crud');
  content_field_instance_delete('field_ccktest', 'my-node-type', FALSE);    
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文