Twig 模板中的 CKEditor + Symfony2
我想在我的 Symfony 2 项目中使用 CK Editor.我下载了 zip 文件,解压缩并将其放在我的 js 文件夹中,我将它包含在我想要编辑器的页面中.我正在关注这个问题点击这里现在我是卡在第 6 步.如何在我的 twig 模板中包含该 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');
?>
我可以用包含 html 的任何变量替换名称并将其从我的控制器传递给查看吗?
Can I replace the name with any variable that contains the html and i pass it from my controller to view ?
谢谢
推荐答案
CKEditor 只需要 HTML 和 Javascript.PHP 文件只是用作实用程序助手来发出正确的 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
文件的链接,并在您的 twig 模板中插入一个带有 ckeditor
类的文本区域.(我还发现我需要一个 id 标签,但它的值是什么并不重要) CKEditor 会处理其余的.
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.
相关文章