2013-02-27 98 views
2

我爲這些類別創建了一個自定義屬性。我認爲我啓用了「'wysiwyg_enabled'=> true」的WYSIWYG編輯器,但所見即所得並沒有顯示出來。爲自定義類別屬性啓用wysiwyg編輯器

$installer->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'shortdescription', array(
    'type'    => 'text', 
    'backend'   => '', 
    'frontend'   => '', 
    'label'    => 'Short description', 
    'input'    => 'textarea', 
    'class'    => '', 
    'source'   => '', 
    'global'   => '0', 
    'visible'   => true, 
    'required'   => false, 
    'user_defined'  => true, 
    'default'   => '', 
    'searchable'  => false, 
    'filterable'  => false, 
    'comparable'  => false, 
    'visible_on_front' => true, 
    'used_in_product_listing' => false, 
    'unique'   => false, 
    'wysiwyg_enabled' => true, 
    'apply_to'   => '', 
    'is_configurable' => true 
)); 

任何幫助,將不勝感激。我使用magento 1.6.2。

+0

是否textarea的顯示沒有所見即所得或沒什麼g顯示出來了嗎? – 2013-02-27 14:20:57

+0

textarea顯示出來,沒有編輯器。 – 2013-02-27 14:50:26

回答

7

嘗試(沒有所有的附加選項)

<?php 
$this->startSetup(); 
$this->addAttribute('catalog_category', 'custom_attribute', array(
    'group'   => 'General', 
    'input'   => 'textarea', 
    'type'   => 'text', 
    'label'   => 'Custom attribute', 
    'backend'  => '', 
    'visible'  => true, 
    'required'  => false, 
    'wysiwyg_enabled' => true, 
    'visible_on_front' => true, 
    'is_html_allowed_on_front' => true, 
    'global'  => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 
)); 

$this->endSetup(); 

假設在你的設置$this->startSetup()是的Mage_Catalog_Model_Resource_Eav_Mysql4_Setup

<global> 
    <resources> 
     <add_category_attribute> 
      <setup> 
       <module>...</module> 
       <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class> 
      </setup> 

瞬間你也可以做

$setup = new Mage_Eav_Model_Entity_Setup('core_setup'); 

$setup->addAttribute('catalog_category' ... 

http://www.atwix.com/magento/add-category-attribute/

+0

謝謝,我會給它一個去看看它是否有效。好像我錯過了'is_html_allowed_on_front'。 – 2013-02-27 14:51:17

+0

它適合我。 – jamapag 2013-02-27 16:38:56

+1

附加說明:如果它不適合你,請確保$ this'是'Mage_Catalog_Model_Resource_Setup'的一個實例,而不僅僅是'Mage_Eav_Model_Entity_Setup'。 – 2013-07-17 07:45:25

1

如果您已經從Magento管理創建的屬性而不是編碼,以下可能會有所幫助:

 Go to admin panel > catalog > manage attributes >
select your attribute(eg. short description) > Attribute Information >
properties > Frontend properties...
Now select 'Yes' from the 'Enable WYSIWYG' dropdown.

+1

它是category屬性,您不能使用magento admin編輯或添加類別屬性。 – jamapag 2013-02-27 14:04:51

+0

但是,如果他們在未來的版本中實現它,我會很高興。 – 2013-02-27 14:51:41

0

創建SQL更新

is_wysiwyg_enabled

$installer->updateAttribute('catalog_category', 'certifications', 'is_wysiwyg_enabled', 1); 

is_html_allowed_on_front

$installer->updateAttribute('catalog_category', 'certifications', 'is_html_allowed_on_front', 1);