CKEditor在Twig Template + Symfony2 [英] CKEditor in Twig Template + Symfony2

查看:201
本文介绍了CKEditor在Twig Template + Symfony2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Symfony 2项目中使用CK编辑器。我下载的zip文件,解压缩并把它放在我的js文件夹,我包括在我想要的编辑器的页面。我正在关注此问题点击此处如何在我的树枝模板中包含该php。

I want to use CK Editor in my Symfony 2 project. I downloaded the zip file, unzipped and put it in my js folder, I included it in the page where I want the Editor. I am following this Question Click Here now I am stuck at step 6. How can I include that php in my twig template.

需要包括的步骤6中的php是

The php that is in step 6 that needs to be included is

<?php

// Make sure you are using a correct path here.
include_once 'ckeditor/ckeditor.php';

$ckeditor = new CKEditor();
$ckeditor->basePath = '/ckeditor/';
$ckeditor->config['filebrowserBrowseUrl'] = '/ckfinder/ckfinder.html';
$ckeditor->config['filebrowserImageBrowseUrl'] = '/ckfinder/ckfinder.html?type=Images';
$ckeditor->config['filebrowserFlashBrowseUrl'] = '/ckfinder/ckfinder.html?type=Flash';
$ckeditor->config['filebrowserUploadUrl'] = '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files';
$ckeditor->config['filebrowserImageUploadUrl'] = '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images';
$ckeditor->config['filebrowserFlashUploadUrl'] = '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash';
$ckeditor->editor('CKEditor1');

?>

感谢

推荐答案

CKEditor只需要HTML和Javascript。

CKEditor only requires HTML and Javascript. The PHP files are simply for use as utility helpers to emit the proper HTML and Javascript.

只需要包含 ckeditor.js

Just include the link to the ckeditor.js file and insert a textarea with the ckeditor class in your twig template. (I also found that I needed an id tag, but it didn't matter what it's value was) CKEditor will handle the rest.

<html>
<head>
    <title>Simple CKEditor Example</title>
    <script type="text/javascript" src="ckeditor.js"></script>
</head>
<body>
    <form action="" method="post">
        <textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="10"></textarea>
        <input type="submit" value="Submit" />
    </form>
</body>
</html>

在引用的示例中,他们还使用 CKFinder 文件管理器。它需要PHP以处理文件管理器功能。该项目的集成说明超出了原始问题的范围。

In the example you quoted, they are also using the CKFinder file manager. It does require PHP in order to handle the file manager functions. Integration instructions for that item are beyond the scope of your original question.

这篇关于CKEditor在Twig Template + Symfony2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆