如何在 Joomla! 中插入 HTML 标签模块标题?
我想做的是将一些 HTML 标签添加到我的 Joomla!模块标题。我需要这样的东西
Some <b>Title</b>
,但是当我保存时!Joomla 会修剪标题并删除所有 HTML 标签。
我检查了administrator/com_content,我认为它应该负责插入数据库数据,但我在那里找不到答案。
谁能帮我解决这个头痛问题吗?
What I'm trying to do is to add some HTML tags to my Joomla! module titles. I will need something like this
Some <b>Title</b>
but when I save !Joomla trims the titles and remove all HTML tags.
I've check the administrator/com_content, which I think should be responsible for inserting the database data, but I couldn't find the answer there.
Can anyone help me with this headache?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看 ../templates/system/html/modules.php
您可以在 HTML 中设置模块结构的样式。
然后在index.php中调用你的样式模块:
Check out ../templates/system/html/modules.php
You can style your module structure in HTML.
Then call your styled module in index.php:
所以我找到了解决方案。它包含之前的两个答案,因此我在这里使用正确的代码放置一个新答案。
首先,我需要说的是,这个解决方案仅适用于固定数量的单词(最后一个、两个等),我只需要最后一个,所以我将发布一个包含一个单词的示例代码。
首先,由于 SMacFadyen 悲伤,我需要在模板 html 文件夹中创建一个新的模块结构:/templates/system/html/modules.php 文件。
注意:如果您不想将这个新模块样式添加到所有模板,而只是在其中一个模板上添加,则需要将 module.php 放入模板的 html 文件夹中。
由 SMacFadyen 看起来像这样:
然后由于 Hanny 的评论而过期 我添加了一些 php 代码来匹配标题的最后一个单词并将其存储在新的变量中。代码看起来像这样:
注意:
$wrap_tag
变量存储您想要的标签。你可以输入 b、em、u 等来得到不同的结果。最后一件事是替换显示的标题,所以我替换了以下代码:
title; ?>
与这个:
最终结果是这样的:
感谢大家的帮助。
So I found the solutions. It includes both of the previous answers, so I'm putting a new one here with the correct code.
First of all I need to say, that this solution works only for a fixed amount of words (last one, two, etc.) I need only to have the last one, so I will post an example code with one word.
First as SMacFadyen sad I needed to create a new module structure in my template html folder: /templates/system/html/modules.php file.
Note: If you don't want to add this new module styling to all templates, but just on one of them you need to put the module.php in your template's html folder.
The provided by SMacFadyen looks like this:
Then expired by the comments of Hanny I've added some php code to match the last word of the title and to store it in a new varibale.The code looks like this:
Note: the
$wrap_tag
variable stores the tag you want. You can put b, em, u and etc. to have different result.The last thing was to replace the displayed title, so I've replaced this code:
<h1><?php echo $module->title; ?></h1>
with this one:
<h1><?php echo $html_title; ?></h1>
The final result was this:
Thanks to everybody for the help.
Gantry 框架可以帮助您完成您想要的任务(第一个单词采用一种方式,第二个单词采用另一种方式) - 但仅完成您正在寻找的一项任务就会产生大量开销。最终,您必须为您的模板创建一个模板覆盖,然后使用 php 进行一些创意编辑,以使其以这种方式显示。
没有快速简便的方法可以完成这项工作。您必须在后端进行一些 php 编码并编辑模板(使用覆盖,这样您就不会破解核心文件)。最终,您可能需要编写 php 代码来分离标题,并使用 CSS 将格式应用于每个分离的单词(或字符串,视情况而定)。
希望有帮助。
The Gantry framework can help you accomplish what you want (1st word styled one way, 2nd word styled another) - but it's a lot of overhead just accomplish that one task you're looking for. Ultimately you'll have to create a template override for your template, and then do some creative editing with php in order to get it to display that way.
There's no quick and easy way to get that done. You'll have to do some php coding on the backend and edit the template (use an override so you don't hack core files). Ultimately you'll probably have to code the php to pull apart the title, and apply formatting to each pulled apart word (or string of words as the case may be) using CSS.
Hope that helps.