joomla 在内容中显示 html
我有一个 joomla 安装程序,它可以正常显示一些文章,但是当我添加带有 youtube 视频的文章时,所见即所得编辑器将嵌入代码中的特殊字符转换为 html 实体。 好吧,我假设它是编辑器,因为当我不使用它时它不会发生。
之后的问题是,如果我转到这篇文章,我会看到 Flash 播放器的嵌入代码,而不是正在渲染的 Flash 播放器。
我正在使用 joomla 1.5 和 php 5 安装。 我以为joomla默认对内容使用html_entity_decode()? 有谁知道为什么会发生这种情况,并可以指导我找到我需要使用该功能的文件或模板文件,谢谢。
I have a joomla isntallation which displays some articles normally but when i added an article with a youtube video, the WYSIWYG editor converted the special characters in the embed code to html entities.
Well, i'm assuming its the editor since it doesn't happen when i don't use it.
The problem after is that if i go to the article, i see the embed code for the flash player, instead of the flash player being rendered.
I'm using joomla 1.5 with a php 5 install.
I thought joomla used html_entity_decode () on content by default?
Does anyone know why this is happening and can guide me to which file or template file i'd need to use the function on please and thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
几乎 joomla 编辑器会从内容中删除 HTML、CSS、JS,
因此您可以在编辑器设置中禁用干净的 HTML,或者
最好使用任何插件来嵌入 YouTube 代码(有很多)
使用此插件嵌入几乎所有提供商(youtube、vimeo、metacaf 等)的视频
http://extensions.joomla.org/extensions/multimedia/video-players-a-gallery/812
Almost joomla editors strip HTML ,css,JS from the content
so you can disable clean HTML in your editor settings or
its better to use any plugin to embed the youtube code (there are a lot )
use this plugin to embed videos from almost any provider (youtube , vimeo , metacafe etc.)
http://extensions.joomla.org/extensions/multimedia/video-players-a-gallery/812
您必须将代码片段嵌入到编辑器生成的 HTML 源代码中。大多数所见即所得编辑器都有一个按钮,可以让您直接查看 HTML;单击它,您应该能够粘贴您的嵌入代码。
但是,您可能需要更改一些设置才能使其完全正常工作。我已经有一段时间没有解决这个问题了,但您可能需要转到 TinyMCE 插件(在插件管理器中)并将“保存时的代码清理”设置为“从不”。文章管理器参数部分中还有一个针对允许的 HTML 标签的过滤器,因此您可能还需要在那里调整黑名单。
You'll have to embed your code snippet in the HTML source that's generated by the editor. Most WYSIWYG editors have a button that allows you to see the HTML directly; click on that and you should be able to paste in your embed code.
There might be some settings that you'll have to change for this to work completely, however. It's been a while since I've fought with this, but you might need to go to the TinyMCE Plugin (in the Plugin Manager) and set "Code Cleanup on Save" to "Never." There's also a filter for allowed HTML tags in the Article Manager parameters section, so you might have to adjust the blacklist there as well.
正如您所收集的,编辑器正在杀死您的代码。造成这种情况的原因有两个 -
建议您使用插件来完成此类操作,因为它可以让您更好地控制用户输入。它保证用于嵌入视频的代码每次都是正确的,并且不会插入额外的代码,因为所有繁重的工作都是由插件处理的。编写良好的插件的额外处理时间是最少的,除非您的网站获得数百万的页面浏览量,否则您不会看到网站性能有任何明显的差异。
如果你真的想通过编辑器来完成,有一个技巧。您不仅必须在编辑器的 HTML 视图中插入代码,而且还必须在代码视图中保存文章。编辑器的 HTML 视图状态通常是持久的,因此您需要确保在返回已插入代码的文章之前处于 HTML 视图中,否则简单地打开该文章就会弄乱您插入的代码。
最后,有一些扩展允许您直接将代码插入到编辑器中。我不喜欢这些,因为它们确实构成安全风险。
As you have gathered the editor is killing your code. There are 2 reasons for this -
It is recommended that you use a plugin for this type of thing because it gives you more control over the users input. It guarantees that the code used to embed the video will be correct every time and that no additional code is being inserted since all of the heavy lifting is handled by the plugin. The additional processing time of a well written plugin is minimal and you will not see any noticeable difference in site performance unless your site gets millions of page views.
If you really want to do it through the editor, there is a trick to it. Not only do you have to insert the code in the HTML view of the editor, but you have to save the article while still in the code view. The HTML view state of the editor is usually persistent so you need to be sure you are in HTML view before you go back in to an article that you have inserted code in, otherwise simply opening the article will mess up the code you inserted.
Last, there are some extensions that allow you to insert code directly in to the editor. I am not a fan of those because they do pose a security risk.