Magento:某些类别的标题,但并非所有类别

时间:2011-10-07 00:04:18

标签: magento

我需要在某些类别上拥有标题标签,但不是全部。它们默认显示,所以我到目前为止所做的是在app / design / frontend / default / my_theme / template / catalog / category中创建一个新的view.phtml文件并注释掉创建标题的部分,哪个工作正常。 下一阶段是在某些类别上启用标题。我这样做是通过手动添加到类别描述,这是好的,但后来我想到了可能创建一个cms块并使用它来做到这一点。要做到这一点,需要有一个标记标记或其他东西来显示我可以放在静态块中的当前类别。有吗?..还是有其他办法吗?

(我已经包含了背景故事,因为这可能是错误的方式来完全打开类别页面上的标题。)

2 个答案:

答案 0 :(得分:1)

你可以用

做到这一点
<layout>
     <your_target_handler>
           <reference name="head">
                <action method="setTitle"><title>Your title</title></action>
           </reference>
     </your_target_handler>
</layout>

或通过php

进行
$this->getLayout()->getBlock('head')->setTitle('my title');

Mage::app()->getLayout()->getBlock('head')->setTitle('my title');

答案 1 :(得分:1)

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

我使用以下代码将额外的(textarea)属性添加到Mage 1.5.0中的类别:

/* 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是什么。

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

希望这会有所帮助;)