Magento:某些类别的标题,但不是所有类别的标题

Magento:某些类别的标题,但不是所有类别的标题,magento,Magento,我需要有某些类别的标题标签,但不是所有的。默认情况下会显示它们,因此到目前为止,我所做的是在app/design/frontend/default/my_theme/template/catalog/category中创建一个新的view.phtml文件,并注释掉创建标题的部分,效果很好。 下一阶段将是启用某些类别的标题。我通过手动将其添加到类别描述中实现了这一点,这是可以的,但随后我想到了创建一个cms块并使用它来实现。要做到这一点,需要有一个标记标记或一些东西来显示我可以放在静态块中的当前类

我需要有某些类别的标题标签,但不是所有的。默认情况下会显示它们,因此到目前为止,我所做的是在app/design/frontend/default/my_theme/template/catalog/category中创建一个新的view.phtml文件,并注释掉创建标题的部分,效果很好。 下一阶段将是启用某些类别的标题。我通过手动将其添加到类别描述中实现了这一点,这是可以的,但随后我想到了创建一个cms块并使用它来实现。要做到这一点,需要有一个标记标记或一些东西来显示我可以放在静态块中的当前类别。有?。。或者还有其他的方法吗

(我加入了背景故事,因为这可能是完全关闭分类页面标题的错误方式。)

你可以用

<layout>
     <your_target_handler>
           <reference name="head">
                <action method="setTitle"><title>Your title</title></action>
           </reference>
     </your_target_handler>
</layout>


您还可以向类别添加一个额外属性,该属性用作显示或不显示标题的开关(以最简单的方式为准)。 然后调整模板代码,以便检查是否必须显示标题

我使用以下代码为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);
/*为类别向MAGENTO后端添加属性
*添加类型
*/
插入eav_属性(实体_类型_id、属性_代码、后端_类型、前端_输入、前端_标签、默认_值、源_模型)
值(9,'类别\来自\数据','文本','文本区域','来自定价文本','');
/*
*资料来源:Q:
*在eav_实体_属性(实体_类型_id、属性_集合_id、属性_组_id、属性_id、排序_顺序)中插入值(3、3、3、);
*工作,但实体类型id对于类别应为9
*/
在eav_实体_属性(实体_类型_id、属性_集合_id、属性_组_id、属性_id、排序_顺序)中插入值(9、12、7、9、25);
/* 
*添加属性本身
*/
插入到'catalog\u eav\u属性'(`attribute_id`、`frontend_input_renderer`、`is_global`、`is_visible`、`is_filterable`、`is_visible_on_front`、`is_html_allowed_on_on_front`、`is_used_for_price_rules`、`is_filterable_in_search`、`is_可在_搜索中过滤`、`is_u产品清单中`is_u `、`used_u用于按`、`排序`、`is_u `、`is_u `、`可配置`、`u `、`u `、`高级位置上`、uu `、,`is_wysiwyg_enabled`)值
(977,NULL,1,0,0,0,0,1,0,0,0,0,0,0,0,1',,0,0,1);
您可能希望检查数据库本身,并在第一次查询后找出eav_entity_属性中包含的实体_type_id 9以及eav_属性中的插入id

对于添加复选框属性,我建议您检查表并查找现有属性,并相应地调整查询中的参数


希望这能有所帮助;)

对不起,也许我不明白,或者我在问题中没有说清楚,但问题的关键是要有这么多的标题DynamicHanks-看起来它会起作用-我离开这个项目几天,但稍后会尝试,听起来它会起作用,谢谢-我是magento的新手-我知道在哪里设置产品属性,但在哪里设置类别属性?@buronyasgur我添加了为我完成任务的SQL。看看它是否对你有帮助,或者至少为你指明了正确的方向。。。
Mage::app()->getLayout()->getBlock('head')->setTitle('my title');
/* 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);