媒体内容编辑器tinyMCE for cakephp 3.7.



我正在使用cakephp 3.7。我试图通过 2 种不同的方式让 tinymce 工作,但它不起作用。首先,我尝试调整以前的 cakephp 2 步骤以使其工作,如 cakephp 文档"https://bakery.cakephp.org/2012/04/11/Helper-TinyMCE-for-CakePHP-2.html"所示,它在我使用 cakephp 2 的先前项目中有效,但在这里它不起作用。其次,我遵循了另一个教程,建议enter code here像插件一样在cakephp 3.7的插件文件夹中使用tinymce,但仍然不起作用。关于如何为 cakephp 3.7 安装 tinymce 的任何帮助? 注意:我通过作曲家以及我使用的所有其他插件获得了我的蛋糕php 3.7,除了我无法用作曲家获得的tinymce。 我有这个错误:方法应用程序\视图\助手\TinymceHelper::d omId 不存在 [CORE/src/View/Helper.php,行。 提前谢谢。

  1. 我下载了 tinymce 并将其设置在 webroot/js 文件夹中
  2. 在应用程序控制器中.php我添加了public $helpers = ['tinymce.tinymce'];
  3. 在视图中显示我在相关文本区域添加的 tinymce 编辑器的位置

    <?php echo $this->Tinymce->input('content', 
    array('label' => 
    'Content'),array('language'=>'en'),'bbcode'); 
    ?>
    

    这是我在 tinymceHelper 中的头.php

use CakeViewHelper;
use CakeViewStringTemplateTrait;
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_simplewysiwyg_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-我在应用程序控制器中引用了它.php

公共$helpers = ['CkEditor.Ck'];

2-在media.ctp中,我通过以下方式调用了文件头部的Ckeditor"

<?php echo $this->Html->script('ckeditor/ckeditor');?>

(这是非常强制性的,因为如果没有这个调用,cakephp 3.x 只会显示一个 空白文本区域)。

3-在加载ckeditor的相关表单元素中,我使用了语法 在此处输入图像描述

<?= echo $this->Ck->input('Media_Content', array('class', 'ckeditor); ?>

4-在我添加的相关布局中 Html->script('https://cdn.ckeditor.com/4.8.0/full/ckeditor.js'); ?>正如Greg Schmidt所建议的那样。 Ckeditor出现了!!

最新更新