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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yhahn’s picture

Status: Active » Fixed

As 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

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

hefox’s picture

Status: Closed (fixed) » Active
FileSize
738 bytes

So 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).

hefox’s picture

Status: Active » Needs review
hefox’s picture

Title: Use feature name as 'module' for exported node types » Node types lost during exported if module key not features, node

Updating title to reflect current situation.

hefox’s picture

FileSize
739 bytes

Screw first patch
Last update today, I swear

hefox’s picture

To 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).

erikwebb’s picture

Version: 6.x-1.0-beta4 » 6.x-1.0
Status: Needs review » Reviewed & tested by the community
FileSize
571 bytes

This solved my problem on a newer version. Attached a new patch with proper formatting, but same code.

hefox’s picture

Version: 6.x-1.0 » 6.x-1.x-dev
Category: feature » bug
Status: Reviewed & tested by the community » Patch (to be ported)

Commited to 6.x; Not sure if patch applies to 7.x, haven't tested.

hefox’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
febbraro’s picture

hefox’s picture

Seems 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?

febbraro’s picture

Version: 7.x-1.x-dev » 6.x-1.1
Status: Patch (to be ported) » Fixed

Yeah. That's a good idea, will track the D7 on the other ticket. Thanks hefox.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.