Php 如何将所见即所得编辑器添加到Magento自定义选项

Php 如何将所见即所得编辑器添加到Magento自定义选项,php,magento,editor,wysiwyg,Php,Magento,Editor,Wysiwyg,我试图在Magentos自定义选项的文本选项下实现所见即所得编辑器,但失败了。我已经搜索了几个组件,但无法将它们组合在一起 我希望编辑器出现在所见即所得值文本区域所在的字段中。 其他来源要么没有详细说明,要么不适用于1.9.1 到目前为止我所拥有的:[WR是companyname,EPO是我的模块] 我发现了这个片段,它用于在cms页面上的_prepareForm函数中放置所见即所得编辑器: <?php if (Mage::getSingleton('cms/wysiwyg_co

我试图在Magentos自定义选项的文本选项下实现所见即所得编辑器,但失败了。我已经搜索了几个组件,但无法将它们组合在一起

我希望编辑器出现在所见即所得值文本区域所在的字段中。

其他来源要么没有详细说明,要么不适用于1.9.1

到目前为止我所拥有的:[WR是companyname,EPO是我的模块]

我发现了这个片段,它用于在cms页面上的_prepareForm函数中放置所见即所得编辑器:

<?php
    if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled() && ($block = $this->getLayout()->getBlock('head'))) {
        $block->setCanLoadTinyMce(true);
    }

    $form = new Varien_Data_Form(array(
        'id' => 'edit_form',
        'action' => $this->getUrl('*/*/save'),
        'method' => 'post'
    ));
    $fieldset = $form->addFieldset('base_fieldset', array(
        'legend' => Mage::helper('wr_epo')->__("Some Information"),
        'class' => 'fieldset-wide',
    ));
    $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config');
    $fieldset->addField('description', 'editor', array(
        'name' => 'description',
        'label' => Mage::helper('wr_epo')->__('Description'),
        'title' => Mage::helper('wr_epo')->__('Description'),
        'style' => 'height: 600px;',
        'wysiwyg' => true,
        'required' => false,
        'config' => $wysiwygConfig
    ));?>

我很久以前就遇到过这样的问题(客户希望在选项中包含自定义内容)。 我不知道这是否正是你想要的。但我所做的是:

我在magento的根目录中创建了一个php文件

然后我添加了这个代码。我在stackoverflow上找到的。如果有人知道它来自哪里,那就更好了

ini_set('display_errors',0);
require_once 'app/Mage.php';
Mage::app();

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');


function createNewAttributeSet($name) {
    Mage::app('default');
    $modelSet = Mage::getModel('eav/entity_attribute_set')
    ->setEntityTypeId(4) // 4 == "catalog/product"
    ->setAttributeSetName($name);
    $modelSet->save();
    $modelSet->initFromSkeleton(4)->save(); // same thing
}

// Replace your attribute name with "extra_info"

$setup->addAttribute('catalog_category', 'extra_info', array(
        'group'             => 'General Information',
        'type'              => 'text',
        'backend'           => '',
        'frontend'          => '',
        'label'             => 'Extra Information',
        'wysiwyg_enabled' => true,
        'visible_on_front' => true,
        'is_html_allowed_on_front' => true,
        'input'             => 'textarea',
        'class'             => '',
        'source'            => 'eav/entity_attribute_source_boolean',
        'global'     => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
        'visible'           => 1,
        'required'          => 0,
        'user_defined'      => 0,
        'default'           => '',
        'searchable'        => 0,
        'filterable'        => 0,
        'comparable'        => 0,
        'visible_on_front'  => 0,
        'unique'            => 0,
        'position'          => 1,
));
$setup->updateAttribute('catalog_category', 'extra_info', 'is_wysiwyg_enabled', 1);
$setup->updateAttribute('catalog_category', 'extra_info', 'is_html_allowed_on_front', 1);
然而,我确实认为你想包括

'wysiwyg_enabled' => true,
而不是

 'wysiwyg' => true,
(这是指您先前粘贴的代码)

其他案文:

我发现有助于解决我的问题的东西:

$block->setCanLoadTinyMce(true)
应该在prepare\u layout函数中。为了便于阅读,你把它组合在这里了吗?(如果没有,则应将其移动)。看起来您已经遵循了,但走了一条捷径,因为此时可能已经添加了布局。这只是添加了一个属性,但您还需要执行许多其他操作,如编辑adminhtml模板文件和覆盖conrollers。