1

我正在尝试从模块中添加新的内容类型,并且我从 ubercart 产品工具包模块中借鉴了很多,因为我想将其用作这种新类型的基础:

/**
* 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'),
        ),
    );
}

但是,这种新的内容类型并未与其他内容类型一起列在我的内容类型列表中。我知道模块加载正确,因为我还创建了一个函数 amh_shop_bundles_perm() 来列出权限,并且它们按预期包含在用户权限列表中。

我错过了什么吗?(嗯,很可能是的)。Drupal 文档说它应该真的那么容易。

更新:

我发现了一条评论,它提供了一个测试内容类型是否正确生成的评论——通过访问 /admin/content/node-type/amh-shop-flexi-bundle

这有效 - 但内容类型仍未与其他内容类型一起列出。

更新 2:

因为我可以在 /node/add/amh-shop-flexi-bundle 访问一个空白节点表单,所以我想我可以继续实现其他挂钩 - 并发现您需要实现 hook_form() 来列出内容类型。

4

1 回答 1

3

实现 hook_form() 的技巧对我有用!

我只添加了这些行,然后 baam:

function hook_form(){
  $form = array();
  return $form;
}
于 2012-01-20T02:20:23.047 回答