加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 如何将WYSIWYG编辑器添加到Magento自定义选项

发布时间:2020-12-13 15:58:30 所属栏目:PHP教程 来源:网络整理
导读:我试图在Magentos自定义选项中的text-option下实现一个所见即所得的编辑器,但我在那里失败了.我已经搜索了几个组件,但是无法将它们组合在一起. 我希望该编辑器出现在WYSIWYG Value-textarea现在所在的领域. 其他来源要么没有详细说明,要么不适用于1.9.1. 到
我试图在Magentos自定义选项中的text-option下实现一个所见即所得的编辑器,但我在那里失败了.我已经搜索了几个组件,但是无法将它们组合在一起.

我希望该编辑器出现在WYSIWYG Value-textarea现在所在的领域.

screenshot of: WYSIWYG shall appear in textarea

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

到目前为止我所拥有的:[WR是公司名称,EPO是我的模块]

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

<?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','is_wysiwyg_enabled',1);
$setup->updateAttribute('catalog_category','is_html_allowed_on_front',1);

我确实认为你想要包括在内

'wysiwyg_enabled' => true,

而不是

'wysiwyg' => true,

(这是指你之前粘贴的代码)

其他阅读:

我发现的事情有助于解决我的问题:
https://www.atwix.com/magento/add-category-attribute/
https://docs.magento.com/m1/ce/user_guide/catalog/product-options-custom.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读