简体   繁体   中英

joomla 3.2 generates item ids as css classes in the html output of e.g. menu elements, is this of any use to me or just ignore it?

I am used to develop simple, eg leave away whatever you don't need. This is why I have a bit a hard time with projects like joomla, because they ship with a lot of things I don't know what it should be good for. Someone knows why these classes are added to the elements? are they of any use to me?

添加的生成项目ID的示例

The cms doesn't use them. Those are just helper classes, there for the benefit of template designers and site builders.

Say you want to highlight a particular menu item by giving it a different color. You could do this:

.item-435 a {color: red} /* turn that particular menu item red */

As @Mark Simpson said, they're not actually used.

If you wish to remove them, go to line 25 of modules/mod_menu/tmpl/default.php and you will find this:

$class = 'item-'.$item->id;

which you can simply change to:

$class = '';

Do note that if you do edit this file, it may get overridden in a Joomla update and thus your changes will be lost. So instead of editing this core file, make a template override

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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