简体   繁体   English

如何将自定义html代码添加到Joomla 2.5菜单项?

[英]How to add custom html-code to Joomla 2.5 menu items?

Situation: I have old site Agroteplica based on Joomla 2.5. 情况:我有一个基于Joomla 2.5的旧站点Agroteplica I need to add custom html-code to menu items (for example, icons, or bold). 我需要将自定义html代码添加到菜单项(例如,图标或粗体)。 I need unic icon for each menu item, so it's no use to edit php-template of page. 我需要为每个菜单项使用unic图标,因此无需编辑页面的php-template。

If I try to use html-code in menu item header - Joomla clear it, only text remains. 如果我尝试在菜单项标题中使用html代码-Joomla清除它,则仅保留文本。 I tried to find some manuals, and added line filter="raw" to file modules.xml : 我试图找到一些手册,并在file modules.xml添加了filter="raw"行:

<field name="title" type="text"
description="COM_MODULES_FIELD_TITLE_DESC"
label="JGLOBAL_TITLE"
maxlength="100"
required="true"
filter="raw"
size="35"
/>

But it didn't give any effect either. 但这也没有任何效果。

Question: what I need to do to make it work? 问题:我需要做些什么才能使其正常工作? :) :)

Here is what Joomla provides for cases like this: 这是Joomla为类似情况提供的内容:

In Menu Manager -> Menu Item Edit 菜单管理器中 -> 菜单项编辑

Editing each menu item, you will see the "Link Type Options" section at the right column. 编辑每个菜单项,您将在右列看到“链接类型选项”部分。

See screenshot: 看截图:

编辑菜单项-链接类型选项

As you see in the screenshot, this group of settings contains the follow options: 如屏幕截图所示,这组设置包含以下选项:

  1. Link Title Attribute : You can add your custom Title attr to the menu item's a tag. 链接标题属性 :您可以将自定义标题属性添加到菜单项的标签。

  2. Link CSS Style : You can add a custom css class for this menu item's a tag. 链接CSS样式 :您可以为此菜单项的标签添加自定义css类。

  3. Link Image : You can add a custom image for this menu item. 链接图像 :您可以为此菜单项添加自定义图像。

  4. Add Menu Title : If you add an image, you can choose to hide the Title of the link (setting = No), or choose to show both Image and the title (setting = yes (default)). 添加菜单标题 :如果添加图像,则可以选择隐藏链接的标题(设置=否),或选择同时显示图像和标题(设置=是(默认))。

For you case, you can either choose you custom images-icons that should be displayed next to your menu items title. 对于您的情况,您可以选择自定义图像图标,这些图标应显示在菜单项标题旁边。 If you want bolds or other styling options, you can add your custom css rules to the items you want, and then add your css styles at your template's css. 如果要使用粗体或其他样式选项,可以将自定义css规则添加到所需的项目,然后在模板的css处添加css样式。

For example you have decided that for some of your menu-items you would want their text in bold. 例如,您已经决定,对于某些菜单项,您希望其文本为粗体。 Then you could do as follow: 然后,您可以执行以下操作:

1 .Give them a css class to all of them, in the Link CSS Style field: eg 'bold-items' (without the ''). 1。在“链接CSS样式”字段中为它们提供一个css类:例如,“ bold-items”(无“”)。 2. Open your template's css file with a plain text editor and add the following rule at the end of the document: 2.使用纯文本编辑器打开模板的css文件,并在文档末尾添加以下规则:

.bold-items {
    font-weight:bold;
}

Notice: The above settings might have no effect at all, if you are using a 3rd party menu module, or your template contains overrides for the default menu module. 注意:如果您使用的是第三方菜单模块,或者您的模板包含默认菜单模块的替代项,则以上设置可能根本无效。 In such case you will need to add further template overrides for the menu module in use, in order to implement the above settings. 在这种情况下,您将需要为正在使用的菜单模块添加更多的模板替代,以实现上述设置。

*Not sure what you mean with menu item header and how you did try to add html-code to it. *不确定菜单项标题是什么意思,以及如何尝试向其中添加html代码。

*Update / Answer to your comment: *更新/回答您的评论:

You never mentioned about video in your question. 您从未在问题中提及视频。 You asked about adding icons and making text bold. 您询问有关添加图标并使文本加粗的问题。 What do you mean with headers and what kind of code and where are you trying to insert it? 您对标头的含义是什么,什么样的代码以及要在哪里插入? Are you aware of what is involved in the process from the moment you create menu items in the menu manager till you see those in the front-end of your website? 从菜单管理器中创建菜单项到在网站前端看到菜单项的那一刻,您是否知道该过程涉及什么?

Following my answer above and assuming you have basic knowledge of the workflow (menu module, template overrides, css) you will be able to add images/icons or custom styles for each menu item. 按照我上面的回答,并假设您具有工作流程的基本知识(菜单模块,模板替代,css),您将能够为每个菜单项添加图像/图标或自定义样式。 If you want to have video inside your menu, then you... 如果您想在菜单中加入视频,那么...

... will need a more sophisticated menu module. ...将需要一个更复杂的菜单模块。 These are called Mega Menus and allow the user to display various types of content inside their menus, like modules, in various ways. 这些被称为超级菜单,允许用户以各种方式在菜单内显示各种类型的内容,例如模块。 You should either install a such module or create one on your own. 您应该安装这样的模块,也可以自己创建一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM