When feature generates implementation of hook_node_info(), all the returned items have 'features' as their 'module'. For instance:
function _my_feature_node_info() {
$items = array(
'mytype' => array(
'name' => t('My Type'),
'module' => 'features', //features as the module for the mytype node type
'description' => t('My type description'),
'has_title' => '1',
'title_label' => t('Title'),
'has_body' => '1',
'body_label' => t('Body'),
'min_word_count' => '0',
'help' => '',
),
);
return $items;
}
Wouldn't it be better to use the exported feature/module name here ? Like this
function _my_feature_node_info() {
$items = array(
'mytype' => array(
'name' => t('My Type'),
'module' => 'my_feature', //my_feature as the module for the mytype node type
'description' => t('My type description'),
'has_title' => '1',
'title_label' => t('Title'),
'has_body' => '1',
'body_label' => t('Body'),
'min_word_count' => '0',
'help' => '',
),
);
return $items;
}
This will allow the use hook_insert, hook_view, etc. when adding custom behaviors to an exported feature.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 654334-node-types-lost-custom-module-name-8.patch | 571 bytes | erikwebb |
| #6 | 654334_module_key.patch | 739 bytes | hefox |
| #3 | 654334_module_key.patch | 738 bytes | hefox |
Comments
Comment #1
yhahn commentedAs I've written here http://drupal.org/node/636402#comment-2396256 there are some reasons why we don't write the default node hooks for you.
If you'd like to override the module name for your feature and write your own hooks, however, this commit should let you do so.
http://drupal.org/cvs?commit=304998
Comment #3
hefox commentedSo I sorta finally got around to testing this, and it doesn't work on features-update without further manual intervention, as features drops the node type if it sees the module key isn't 'node' or 'features'.
Patch adds in a || isset map type (early check sees if isset and NOT module, so this check results in isset AND module defines the type).
Comment #4
hefox commentedComment #5
hefox commentedUpdating title to reflect current situation.
Comment #6
hefox commentedScrew first patch
Last update today, I swear
Comment #7
hefox commentedTo test.
1) Export a feature with a node type
2) Edit the hook_node_info in mymodule.features.inc and change 'features' for key 'module' to a non-existant module (ie. 'blahblah')
3) Features up the feature (drush fu -y mymodule).
Comment #8
erikwebb commentedThis solved my problem on a newer version. Attached a new patch with proper formatting, but same code.
Comment #9
hefox commentedCommited to 6.x; Not sure if patch applies to 7.x, haven't tested.
Comment #10
hefox commentedComment #11
febbraro commentedPossible relation to #1215292: Node type provided by a feature not exported properly.
Comment #12
hefox commentedSeems extremely related from a brief look. Shall this be 'fixed' for 6.x and let that issue cover as that one has the updated patch?
Comment #13
febbraro commentedYeah. That's a good idea, will track the D7 on the other ticket. Thanks hefox.