[英]How to use TinyMCE editor in symfony2 twig file with textarea
I am not able to get TinyMCE editor into my twig file.我无法将 TinyMCE 编辑器放入我的树枝文件中。 my twig file code is as below我的树枝文件代码如下
{% block content %}
{{ tinymce_init() }}
<div class="content">
<h2 class="pg-title">Add emailTemplate</h2>
<div class="specialty adProvier">
<form action="{{ path('_admin_new_emailTemplate') }}" method="post" {{ form_enctype(form) }} class="specialtyForm" id="add-emailTemplate">
{{ form_row(form._token) }}
{{ form_row(form.templateKeyword) }}
{{ form_row(form.senderEmail) }}
{{ form_row(form.translations)}}
{{ form_row(form.isActive) }}
{{ form_rest(form) }}
<div class="buttons">
<input type="submit" id="save" class="button" value="Save" />
<input type="button" id="cancel" class="button" value="Cancel" />
</div>
</form>
</div>
</div>
{% endblock %}
{% block javascripts %}
<script type="text/javascript" src="{{ asset('bundles/dashboardadmin/js/admin.js') }}"></script>
<script type="text/javascript" src="{{ asset('bundles/stfalcontinymce/js/init.jquery.js') }}"></script>
<script type="text/javascript" src="{{ asset('bundles/stfalcontinymce/js/init.standard.js') }}"></script>
<script type="text/javascript" src="{{ asset('bundles/stfalcontinymce/js/ready.min.js') }}"></script>
<script type="text/javascript">
tinymce.init({
selector: 'textarea',
});
</script>
{% endblock %}
My Form builder file has the below code:我的表单构建器文件具有以下代码:
$builder->add('content', 'textarea', array(
'attr' => array(
'label' => 'Content:',
'class' => 'tinymce',
'data-theme' => 'simple' // simple, advanced, bbcode
)
));
Now my problem is that im not able to see tinyMce editor for my Content textarea..现在我的问题是我无法看到我的内容文本区域的 tinyMce 编辑器..
im just getting a simple textarea field.我只是得到一个简单的 textarea 字段。
Please help me getting the tinyMCE editor请帮我获取tinyMCE编辑器
I suggest you to use the {{ tinymce_init() }}
function in your Twig template (it will save you from using {{ asset() }}
) andconfigure TinyMCE with app/config/config.yml file .我建议您在 Twig 模板中使用{{ tinymce_init() }}
函数(它可以使您免于使用{{ asset() }}
)并使用 app/config/config.yml 文件配置 TinyMCE 。 With the ".tinymce" selector and the "tinymce" class on your <teaxtarea>
, it should work.使用<teaxtarea>
上的“.tinymce”选择器和“tinymce”类,它应该可以工作。 The TinyMCE configuration is detailed in its documentation . TinyMCE 配置在其文档中有详细说明。
I suggest you this simple configuration :我建议你这个简单的配置:
stfalcon_tinymce:
include_jquery: false
tinymce_jquery: true
selector: ".tinymce"
Have you checked that TinyMCE is properly installed in your bundles ?您是否检查过 TinyMCE 是否正确安装在您的包中? Do you see TinyMCE when running the php app/console assets:install web --symlink
command ?运行php app/console assets:install web --symlink
命令时是否看到 TinyMCE? Have you cleared your browser's cache ?您是否清除了浏览器的缓存?
you are following JavaScript use in your twig file您正在关注树枝文件中的 JavaScript 使用
INCLUDE IN THIS SCRIPT http://tinymce.cachefly.net/4.0/tinymce.min.js
包括在本脚本中http://tinymce.cachefly.net/4.0/tinymce.min.js
<script src="http://tinymce.cachefly.net/4.0/tinymce.min.js"></script>
tinymce.init({
selector: '.absurls',
plugins: 'link image code',
relative_urls: false
});
tinymce.init({
selector: '#abshosturls',
plugins: 'link image code',
relative_urls: false,
remove_script_host: false
});
tinymce.init({
selector: '#relurls',
plugins: 'link image code',
relative_urls: true
});
tinymce.init({
selector: '#relurlstopage',
plugins: 'link image code',
relative_urls: true,
document_base_url: 'http://www.tinymce.com/tryit/'
});
tinymce.init({
selector: "#nourlconvert",
plugins: 'link image code',
convert_urls: false
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.