CKEditor in Twig Template + Symfony2(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.
这篇关于Twig 模板中的 CKEditor + Symfony2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Twig 模板中的 CKEditor + Symfony2
基础教程推荐
- 在多维数组中查找最大值 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01