1 node_hooks_example.install node_hooks_example_install()

Implements hook_install().

We need to set a default node_hooks_example_node_type_<contentType> setting to 0 for each available content type. Normally, the default values for a config values would be provided in a static file, but in this case the config values depend from the content types defined by a site. We call node_type_get_types() to get a list of all the content types.

File

modules/examples/node_hooks_example/node_hooks_example.install, line 58
Install, update and uninstall functions for the nodeapi_example module.

Code

function node_hooks_example_install() {
  $config = config('node_hooks_example.settings');
  $node_types = array_keys(node_type_get_types());

  foreach ($node_types as $type) {
    $config->set('node_type_' . $type, 0);
  }

  $config->save();
}