您还可以为类别添加一个额外的属性,用作显示或不显示标题的开关(无论哪种方式最简单)。
然后调整模板代码,使其检查是否必须显示标题。
我使用以下代码在 Mage 1.5.0 中为类别添加额外的 (textarea) 属性:
/* ADD ATTRIBUTES TO MAGENTO BACKEND FOR CATEGORIES
* Adding the type
*/
INSERT INTO eav_attribute (entity_type_id, attribute_code, backend_type, frontend_input, frontend_label, default_value, source_model)
VALUES (9, 'category_from_data', 'text', 'textarea', 'From pricing text', '', '');
/*
* Source Q:
* INSERT INTO eav_entity_attribute ( entity_type_id, attribute_set_id, attribute_group_id, attribute_id, sort_order ) VALUES ( 3, 3, 3, <new attribute ID>, <next sort order> );
* Works but entity_type_id should be 9 for category
*/
INSERT INTO eav_entity_attribute ( entity_type_id, attribute_set_id, attribute_group_id, attribute_id, sort_order ) VALUES ( 9, 12, 7, 9, 25 );
/*
* Adding the attribute itself
*/
INSERT INTO `catalog_eav_attribute` (`attribute_id`, `frontend_input_renderer`, `is_global`, `is_visible`, `is_searchable`, `is_filterable`, `is_comparable`, `is_visible_on_front`, `is_html_allowed_on_front`, `is_used_for_price_rules`, `is_filterable_in_search`, `used_in_product_listing`, `used_for_sort_by`, `is_configurable`, `apply_to`, `is_visible_in_advanced_search`, `position`, `is_wysiwyg_enabled`) VALUES
(977, NULL, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, '', 0, 0, 1);
您可能想检查数据库本身并找出 eav_entity_attribute 中包含的 entity_type_id 9 以及第一次查询后 eav_attribute 中的插入 id 是什么。
对于添加复选框属性,我建议您检查表并查找现有属性并相应地调整查询中的参数。
希望这会有所帮助;)