开发者

hook_node_info is not adding content type to my list

I'm trying to add a new content type from within a module, and I have pretty much borrowed from the ubercart product kit module, since I want to use that as a base for this new type:

/**
* Implementation of hook_node_info().
*
* @return Node type information for flexible product bundles.
*/
function amh_shop_bundles_node_info() {
    return array(
        'amh_shop_flexi_bundle' => array(
            'name' => t('Flexible Product Bundle'),
            'module' => 'amh_shop_bundles',
            'description' => t('This node represents a flexible bundle package that allows customers to mix and match products and get discounts.'),
            'title_label' => t('Name'),
            'body_label' => t('Description'),
        ),
    );
}

But, this new content type isn't being listed in my content types list with the others. I know that the module is loading correctly, as I also created a function amh_shop_bundles_perm() to list permissions, and they are being included in the user permissions listing as expected.

Have I missed something? (Well, most likely, yes). The Drupal documentation says it should really be that easy though.

Update:

I found a comment which provided a test for if the content type is properly generated - by accessing /admin/content/node-type/amh-shop-flexi-bundle

This worked - but the content type is still not listed with the others.

开发者_StackOverflow

Update 2:

Since I could access a blank node form at /node/add/amh-shop-flexi-bundle I figured I could move on with implementing other hooks - and discovered that you need to implement hook_form() to list the content type.


The tip to implement hook_form() did the trick for me!

I added just these lines, and baam:

function hook_form(){
  $form = array();
  return $form;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜