gpt4 book ai didi

wysiwyg - 使用 magento 1.5.2 的图像插入成功添加所见即所得编辑器

转载 作者:行者123 更新时间:2023-12-04 05:06:24 25 4
gpt4 key购买 nike

我们如何在 magento 自定义模块中添加所见即所得编辑器?

最佳答案

1) 打开文件 Block_Adminhtml__Edit_Tab_Form

编辑字段

$form = new Varien_Data_Form();
$this->setForm($form);
$fieldset = $form->addFieldset('developerpage_form', array('legend'=>Mage::helper('developerpage')->__('Item information')));

/* 在此处添加以下代码 */
  $configSettings = Mage::getSingleton('cms/wysiwyg_config')->getConfig();
$configSettings['files_browser_window_url'] = $this->getBaseUrl().'admin/cms_wysiwyg_images/index/';
Mage::getSingleton('cms/wysiwyg_config')->setConfig($configSettings);

/* 字段集添加如下 */
$fieldset->addField('detail', 'editor', array(
'name' => 'detail',
'label' => Mage::helper('developerpage')->__('Content'),
'title' => Mage::helper('developerpage')->__('Content'),
'style' => 'width:700px; height:500px;',
'config' => $configSettings,
'required' => true,

));

2)打开controllers/adminhtml/testcustomercontroller.php 找到editAction

在 editAction 中找到 $this->loadLayout();
并粘贴以下代码;
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
}

3) 打开 desing/adminhtml/default/default/yourmodule xml 文件并在下面添加 xml
 /* this is my module change with yours */
<developerpage_adminhtml_developerpage_edit>
<update handle="editor" />
</developerpage_adminhtml_developerpage_edit>

NOTE: Dont give field name or id name "content" of editor field nor in Database

Call editor content like below other wise directive would't convert

$_cmsHelper = Mage::helper('cms');
$_process = $_cmsHelper->getBlockTemplateProcessor();
echo $_process->filter(Here your database content);

现在可以插入图像。 :)

关于wysiwyg - 使用 magento 1.5.2 的图像插入成功添加所见即所得编辑器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15495039/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com