首页 文章

如何在蛋糕php 2.3中使用CKEditor

提问于
浏览
0

我想在蛋糕php 2.3中使用CKEditor,尝试了很多但没有得到任何解决方案 . 基本上我需要从本地系统编辑器中的图像上传选项 .

我怎么能成功?

3 回答

  • 1

    经过大量的研究,最后我得到了在cakephp 2.3中实现带有图像上传选项的CKEditor的解决方案

    要在CKEditor中上传图片,您必须使用KCFinder,请查看以下链接,您可以在那里获取详细信息

    http://cakephpclues.blogspot.in/2012/01/ckeditor-kcfinder-integration-with.html

    此外,CKEditor还有3个包

    • 基本套餐

    • 标准包装

    • 完整套餐

    还有一个选项可以自定义编辑器工具栏以下载CKEditor,请访问 - http://ckeditor.com/download

  • 1

    Download CKEditor并将文件解压缩到app / webroot / js / ckeditor

    现在在您的ctp文件中添加以下代码,以便ckeditor.js文件将集成到页面的head部分 .

    <?php echo $this->Html->script('ckeditor/ckeditor', array('inline' => false));?>
    

    注意:在Layouts / default.ctp中确认下面的代码放在头部

    <?php echo $scripts_for_layout; ?>
    

    现在将类添加到要应用CKEditor特征的表单元素:

    <?php echo $this->Form->textarea('myelement', array('class'=>'ckeditor')); ?>
    

    现在运行你的文件..它完成..!

    为了更改CKEditor的其他属性,如宽度,高度和工具栏设置,请在ctp文件中添加代码 . (你可以将它粘贴到ctp文件的末尾)

    <script type="text/javascript">
        CKEDITOR.replace( 'textarea_id', {
        toolbar: [[ 'Bold', 'Italic','Underline','Subscript','Superscript'],],
        width: '700',
        height: '100',
        });
    </script>
    
  • 4

    网站编辑对于使内容更加美观非常重要,因此我们将看到CKEditor和CKFinder与cakephp 2.x的集成 .

    enter image description here

    创建编辑助手:EditorHelper.php

    <?php
    class EditorHelper extends Helper
    {
     function loadCK($id){
     $buff = "<script type=\"text/javascript\">
     //<![CDATA[
     var editor_$id = CKEDITOR.replace('$id', {customConfig : '/js/editor/config.js'});
     CKFinder.SetupCKEditor( editor_$id, '/js/ckfinder/' );
     //]]>
     </script>";
     return $buff;
     }
    }
    ?>
    

    其次我们将在控制器中调用它:

    <?php
        public $helpers = array('Editor');
    ?>
    

    第三,我们将创建视图:form.ctp

    <script src="/js/editor/ckeditor.js" type="text/javascript"></script>
    <script src="/js/ckfinder/ckfinder.js" type="text/javascript"></script>
    
    <?php echo $this->Form->textarea('Item.content', array('size' => '32')); ?>
    <?php echo $this->Editor->loadCK ('PagetextContent');  ?>
    

    从源http://ckeditor.com下载ckeditor和ckfinder后,我们将它们放在/ webroot / js /文件夹中 .

    就是这样,希望它有用 .

相关问题