【问题标题】:Enable wysiwyg editor for custom category attribute为自定义类别属性启用所见即所得编辑器
【发布时间】:2013-02-27 12:22:33
【问题描述】:

我为类别创建了一个自定义属性。我以为我用“'wysiwyg_enabled' => true”启用了所见即所得编辑器,但所见即所得没有显示出来。

$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。

【问题讨论】:

  • textarea 是在没有所见即所得的情况下显示还是什么都不显示?
  • 文本区域出现了,只是没有编辑器。

标签: magento magento-1.6


【解决方案1】:

尝试(不使用所有其他选项)

 <?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-&gt;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/

【讨论】:

  • 谢谢,我会试试看它是否有效。好像我错过了“is_html_allowed_on_front”。
  • 附加说明:如果它不适合您,请确保 $this` 是 Mage_Catalog_Model_Resource_Setup 的实例,而不仅仅是 Mage_Eav_Model_Entity_Setup
  • 对我来说,关键是删除其他选项,正如答案中所解释的那样 - 我尝试了几次,只有在我摆脱了其他参数后它才起作用。我使用了&lt;class&gt;Mage_Catalog_Model_Resource_Eav_Mysql4_Setup&lt;/class&gt;$this-&gt;startSetup(),$this-&gt;addAttribute('catalog_category',...)等方法。
【解决方案2】:

如果您是从 magento 管理员而不是通过编码创建属性,以下可能会有所帮助:

 转到管理面板 > 目录 > 管理属性 > 
选择您的属性(例如简短描述)> 属性信息 >
属性 > 前端属性...
现在从“选择”中选择“是”启用所见即所得的下拉菜单。

【讨论】:

  • 是category属性,不能用magento admin编辑或添加category属性。
  • 如果他们在未来的版本中实现这一点,我会很好。
【解决方案3】:

创建一个 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);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-04
    • 1970-01-01
    • 2014-02-01
    • 1970-01-01
    相关资源
    最近更新 更多