簡體   English   中英

如何將WYSIWYG編輯器添加到Magento自定義選項

[英]How to add a WYSIWYG editor to Magento custom options

我試圖在Magentos自定義選項中的text-option下實現一個所見即所得的編輯器,但我在那里失敗了。 我已經搜索了幾個組件,但是無法將它們組合在一起。

我希望該編輯器出現在WYSIWYG Value-textarea現在所在的領域。 截圖:WYSIWYG將出現在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', 'extra_info', 'is_wysiwyg_enabled', 1);
$setup->updateAttribute('catalog_category', 'extra_info', '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的

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM