joomla 在内容中显示 html

发布于 2024-09-13 19:24:43 字数 303 浏览 6 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

小糖芽 2024-09-20 19:24:43

几乎 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

冧九 2024-09-20 19:24:43

您必须将代码片段嵌入到编辑器生成的 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.

萌辣 2024-09-20 19:24:43

正如您所收集的,编辑器正在杀死您的代码。造成这种情况的原因有两个 -

  1. 如果您插入代码,很容易出现格式错误的代码,从而破坏页面下游的某些内容。漏掉一个就会杀死一个页面。
  2. 出于安全原因。您不希望人们能够从编辑器插入恶意代码。一般来说,最好清除用户的所有输入以防止各种攻击。

建议您使用插件来完成此类操作,因为它可以让您更好地控制用户输入。它保证用于嵌入视频的代码每次都是正确的,并且不会插入额外的代码,因为所有繁重的工作都是由插件处理的。编写良好的插件的额外处理时间是最少的,除非您的网站获得数百万的页面浏览量,否则您不会看到网站性能有任何明显的差异。

如果你真的想通过编辑器来完成,有一个技巧。您不仅必须在编辑器的 HTML 视图中插入代码,而且还必须在代码视图中保存文章。编辑器的 HTML 视图状态通常是持久的,因此您需要确保在返回已插入代码的文章之前处于 HTML 视图中,否则简单地打开该文章就会弄乱您插入的代码。

最后,有一些扩展允许您直接将代码插入到编辑器中。我不喜欢这些,因为它们确实构成安全风险。

As you have gathered the editor is killing your code. There are 2 reasons for this -

  1. If you insert code it is easy to have badly formed code that will break something downstream on the page. Leaving out a single will kill a page.
  2. For security reasons. You don't want people being able to insert nefarious code from the editor. In general, it's a good idea to clean any input from a user to prevent all kinds of attacks.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文