用于 cakephp 3.7 的媒体内容编辑器 tinyMCE
Media Content editor tinyMCE for cakephp 3.7
我正在使用蛋糕php 3.7。我试图通过两种不同的方式让 tinymce 工作,但它不起作用。首先,我尝试调整以前的 cakephp 2 个步骤使其工作,如 cakephp 文档中所示“https://bakery.cakephp.org/2012/04/11/Helper-TinyMCE-for-CakePHP-2.html”,它在我使用 cake[ 的上一个项目中工作=38=] 2,但是这里不行。其次,我按照另一个教程建议 enter code here
在 cakephp 3.7 的插件文件夹中使用 tinymce 就像插件一样,但仍然无法正常工作。关于如何为 cakephp 3.7 安装 tinymce 的任何帮助?
N.B:我通过 composer 获得了我的蛋糕php 3.7 以及我使用的所有其他插件,除了 tinymce,我无法使用 composer。
我遇到此错误:方法 App\View\Helper\TinymceHelper::domId 不存在 [CORE/src/View/Helper.php,行。
提前致谢。
- 我下载了tinymce并设置在webroot/js文件夹
- 在AppController.php我添加了
public $helpers = ['tinymce.tinymce'];
我在相关文本区添加的tinymce编辑器的显示视图
<?php echo $this->Tinymce->input('content',
array('label' =>
'Content'),array('language'=>'en'),'bbcode');
?>
这是我在tinymceHelper.php
中的头
use Cake\View\Helper;
use Cake\View\StringTemplateTrait;
class TinymceHelper extends Helper
{
// Take advantage of other helpers
public $helpers = array('Js', 'Html', 'Form');
...}
或者您可能还知道另一个与 cakephp 3.7 更相关的内容编辑器。谢谢你们!
我从 TinyMCE 切换到 CKEDITOR。我没有任何帮手,只是:
- 在布局中加载 JS (
echo $this->Html->script('https://cdn.ckeditor.com/4.8.0/full/ckeditor.js');
)
- 根据需要在输入中输入相关的 类(例如
wysiwyg_simple
或 wysiwyg_advanced
)(echo $this->Form->input('description', ['class' => 'wysiwyg_simple']);
)
- 有一个初始化函数,如下所示,从
onReady
调用(以及当可能包含文本区域的动态内容加载到页面时)
if (typeof CKEDITOR !== 'undefined') {
for(name in CKEDITOR.instances) {
CKEDITOR.instances[name].destroy(true);
}
CKEDITOR.replaceAll(function (textarea, config) {
if (jQuery(textarea).hasClass('wysiwyg_advanced')) {
config.toolbar = [
{
name: 'clipboard',
items: ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']
},
{name: 'editing', items: ['SpellChecker', 'Scayt']},
{name: 'links', items: ['Link', 'Unlink', 'Anchor']},
{name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar', 'PageBreak']},
'/',
{
name: 'basicstyles',
items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat']
},
{
name: 'paragraph',
items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv',
'-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock']
},
'/',
{name: 'styles', items: ['Format', 'Font', 'FontSize']},
{name: 'colors', items: ['TextColor', 'BGColor']},
{name: 'tools', items: ['Maximize', 'ShowBlocks', '-', 'About']},
{name: 'document', items: ['Source']}
];
} else if (jQuery(textarea).hasClass('wysiwyg_simple')) {
config.toolbar = [
{name: 'clipboard', items: ['Cut', 'Copy', 'PasteText', '-', 'Undo', 'Redo']},
{
name: 'basicstyles',
items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat']
},
{name: 'paragraph', items: ['NumberedList', 'BulletedList']},
{name: 'styles', items: ['Format']}
];
} else {
return false;
}
config.resize_dir = 'both';
});
}
经过一段时间的研究并在@Greg Schmidt 的建议下,我得到了 Ckeditor,它不是作为插件而是在 js 文件夹中。
1- 我在 AppController.php 和
中提到了它
public $helpers = ['CkEditor.Ck'];
2- 在 media.ctp 中,我通过“
在文件头部调用了 Ckeditor
<?php echo $this->Html->script('ckeditor/ckeditor');?>
(这是非常强制性的,因为如果没有这个调用,cakephp 3.x 只会显示一个
空白文本区域)。
3- 在加载 ckeditor 的相关表单元素中,我使用了语法
enter image description here
<?= echo $this->Ck->input('Media_Content', array('class', 'ckeditor); ?>
4-在我添加的相关布局中
Html->脚本('https://cdn.ckeditor.com/4.8.0/full/ckeditor.js'); ?> 正如 Greg Schmidt 所建议的那样。
Ckeditor 出现了!!!
我正在使用蛋糕php 3.7。我试图通过两种不同的方式让 tinymce 工作,但它不起作用。首先,我尝试调整以前的 cakephp 2 个步骤使其工作,如 cakephp 文档中所示“https://bakery.cakephp.org/2012/04/11/Helper-TinyMCE-for-CakePHP-2.html”,它在我使用 cake[ 的上一个项目中工作=38=] 2,但是这里不行。其次,我按照另一个教程建议 enter code here
在 cakephp 3.7 的插件文件夹中使用 tinymce 就像插件一样,但仍然无法正常工作。关于如何为 cakephp 3.7 安装 tinymce 的任何帮助?
N.B:我通过 composer 获得了我的蛋糕php 3.7 以及我使用的所有其他插件,除了 tinymce,我无法使用 composer。
我遇到此错误:方法 App\View\Helper\TinymceHelper::domId 不存在 [CORE/src/View/Helper.php,行。
提前致谢。
- 我下载了tinymce并设置在webroot/js文件夹
- 在AppController.php我添加了
public $helpers = ['tinymce.tinymce'];
我在相关文本区添加的tinymce编辑器的显示视图
<?php echo $this->Tinymce->input('content', array('label' => 'Content'),array('language'=>'en'),'bbcode'); ?>
这是我在tinymceHelper.php
中的头
use Cake\View\Helper;
use Cake\View\StringTemplateTrait;
class TinymceHelper extends Helper
{
// Take advantage of other helpers
public $helpers = array('Js', 'Html', 'Form');
...}
或者您可能还知道另一个与 cakephp 3.7 更相关的内容编辑器。谢谢你们!
我从 TinyMCE 切换到 CKEDITOR。我没有任何帮手,只是:
- 在布局中加载 JS (
echo $this->Html->script('https://cdn.ckeditor.com/4.8.0/full/ckeditor.js');
) - 根据需要在输入中输入相关的 类(例如
wysiwyg_simple
或wysiwyg_advanced
)(echo $this->Form->input('description', ['class' => 'wysiwyg_simple']);
) - 有一个初始化函数,如下所示,从
onReady
调用(以及当可能包含文本区域的动态内容加载到页面时)
if (typeof CKEDITOR !== 'undefined') {
for(name in CKEDITOR.instances) {
CKEDITOR.instances[name].destroy(true);
}
CKEDITOR.replaceAll(function (textarea, config) {
if (jQuery(textarea).hasClass('wysiwyg_advanced')) {
config.toolbar = [
{
name: 'clipboard',
items: ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']
},
{name: 'editing', items: ['SpellChecker', 'Scayt']},
{name: 'links', items: ['Link', 'Unlink', 'Anchor']},
{name: 'insert', items: ['Image', 'Table', 'HorizontalRule', 'SpecialChar', 'PageBreak']},
'/',
{
name: 'basicstyles',
items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat']
},
{
name: 'paragraph',
items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv',
'-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock']
},
'/',
{name: 'styles', items: ['Format', 'Font', 'FontSize']},
{name: 'colors', items: ['TextColor', 'BGColor']},
{name: 'tools', items: ['Maximize', 'ShowBlocks', '-', 'About']},
{name: 'document', items: ['Source']}
];
} else if (jQuery(textarea).hasClass('wysiwyg_simple')) {
config.toolbar = [
{name: 'clipboard', items: ['Cut', 'Copy', 'PasteText', '-', 'Undo', 'Redo']},
{
name: 'basicstyles',
items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat']
},
{name: 'paragraph', items: ['NumberedList', 'BulletedList']},
{name: 'styles', items: ['Format']}
];
} else {
return false;
}
config.resize_dir = 'both';
});
}
经过一段时间的研究并在@Greg Schmidt 的建议下,我得到了 Ckeditor,它不是作为插件而是在 js 文件夹中。 1- 我在 AppController.php 和
中提到了它public $helpers = ['CkEditor.Ck'];
2- 在 media.ctp 中,我通过“
在文件头部调用了 Ckeditor<?php echo $this->Html->script('ckeditor/ckeditor');?>
(这是非常强制性的,因为如果没有这个调用,cakephp 3.x 只会显示一个 空白文本区域)。
3- 在加载 ckeditor 的相关表单元素中,我使用了语法 enter image description here
<?= echo $this->Ck->input('Media_Content', array('class', 'ckeditor); ?>
4-在我添加的相关布局中 Html->脚本('https://cdn.ckeditor.com/4.8.0/full/ckeditor.js'); ?> 正如 Greg Schmidt 所建议的那样。 Ckeditor 出现了!!!