2011-10-07 94 views
0

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

(我已经包含了背景故事,因为也许这是错误的方式去完全转向标题折类别页。)

回答

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'); 
+0

抱歉,也许我不明白,也许我没能在这个问题清楚,但整个的一点是要有标题动态 – byronyasgur

+0

那么即使我编辑更容易我的回答 –

+0

非常感谢 - 看起来像它会工作 - 我关闭了这个项目几天,但将尝试后, – byronyasgur

1

您还可以将额外的属性添加到作为显示或不显示标题(无论哪种方式最简单)的开关的类别中。 比调整模板代码,以便检查标题是否必须显示。

我用下面的代码添加额外的(文本域)在法师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); 

你可能要检查数据库本身,并找出entity_type_id 9持有eav_entity_attribute什么eav_attribute中的insert id在第一次查询之后。

为了添加一个复选框属性,我建议你检查一下表格并钓鱼一个现有的属性,并相应地调整查询中的参数。

希望这有助于;)

+0

,听起来像它会工作,谢谢 - 我是新的magento - 我知道在哪里设置产品属性但我在哪里设置类别属性? – byronyasgur

+0

@buronyasgur我添加了为我完成工作的SQL。看看它是否对你有帮助,或者至少让你朝着正确的方向前进...... – Wgenie

相关问题