duanlin1931 2014-10-19 03:43
浏览 88
已采纳

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

Situation: I have old site Agroteplica based on Joomla 2.5. I need to add custom html-code to menu items (for example, icons, or bold). I need unic icon for each menu item, so it's no use to edit php-template of page.

If I try to use html-code in menu item header - Joomla clear it, only text remains. I tried to find some manuals, and added line filter="raw" to file modules.xml:

<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? :)

  • 写回答

1条回答 默认 最新

  • douduan5753 2014-10-19 08:14
    关注

    Here is what Joomla provides for cases like this:

    In Menu Manager -> Menu Item Edit

    Editing each menu item, you will see the "Link Type Options" section at the right column.

    See screenshot:

    Edit Menu Item - Link Type Options

    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.

    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.

    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: e.g. 'bold-items' (without the ''). 2. Open your template's css file with a plain text editor and add the following rule at the end of the document:

    .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.

    *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. 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.

    展开全部

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 Android系统裁剪
  • ¥15 雄安新区高光谱数据集的下载网址打不开
  • ¥66 android运行时native和graphics内存详细信息获取
  • ¥100 求一个c#通过CH341读取数据的Demo,能够读取指定地址值的功能
  • ¥15 rk3566 Android11 USB摄像头 微信
  • ¥15 torch框架下的强化学习DQN训练奖励值浮动过低,希望指导如何调整
  • ¥35 西门子博图v16安装密钥提示CryptAcquireContext MS_DEF_PROV Error of containger opening
  • ¥15 mes系统扫码追溯功能
  • ¥40 selenium访问信用中国
  • ¥20 在搭建fabric网络过程中遇到“无法使用新的生命周期”的报错
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部