2011-10-07 35 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

相關問題