Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drupal programmatically delete node type and/or cck fields

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.

like image 578
sisko Avatar asked Aug 14 '26 18:08

sisko


1 Answers

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);    
}
like image 74
Clive Avatar answered Aug 17 '26 08:08

Clive



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!