joomla 1.5 give every menuitem the class of its alias

830 Views Asked by At

Is there a way to render the alias e.g. 'hidden' of a menu item in the list output of the menu. (Joomla 1.5)

<ul class="topnav">
<li class="item1 menualias">link</li>
<li class="item2 parent active menualias">link</li>
    <ul class="sublevel01">
    <li class="item1 menualias">link</li>
    <li class="item2 active menualias">link</li>
    <li class="item3  menualias">link</li>
    <li class="item4 menualias-is-hidden">link</li>   <- this item should not be visible but its childs
      <ul class="sublevel03">
        <li class="item1 menualias">link</li>
        <li class="item2 menualias">link</li>
        <li class="item3 menualias">link</li>
       </ul>

    </ul>
<li class="item3 menualias">link</li>
</ul>

Best Regards Nico

2

There are 2 best solutions below

0
On

It's technically possible to add the menu alias as a class to each menu item, it can be done with an override by editing JOOMLA/modules/mod_mainmenu/tmpl/default.php and saving it as JOOMLA/templates/YOUR TEMPLATE/mod_mainmenu/default.php. The example you indicated above would not work however, there is an error in your code. The way unordered lists work, a child list is contained within the parent list item. You have:

<li class="item4 menualias-is-hidden">link</li>   <- this item should not be visible but its childs
  <ul class="sublevel03">
    <li class="item1 menualias">link</li>
    <li class="item2 menualias">link</li>
    <li class="item3 menualias">link</li>
   </ul>

It should be:

<li class="item4 menualias-is-hidden">link   <- this item should not be visible but its childs
  <ul class="sublevel03">
    <li class="item1 menualias">link</li>
    <li class="item2 menualias">link</li>
    <li class="item3 menualias">link</li>
   </ul>
</li>

If you make the parent hidden, then all of it's children will be hidden as well. Not really sure the purpose of adding the menu alias because the item# is unique to a menu item. Anything you would apply to the class menualias could also be applied to item# with the added advantage that the there are no duplicates. Menu alias does not have to be unique so you could run in to problems.

0
On

thanks for youre answwer. You're right usally the submenu will disapear if I display:none the parent. But if I use a Splitmenu (what I do) it works.

And you're right, I could use the itemid do disable the menuitem but if someone alter the strukture of the Menu I have to go into css file again. So I thought its better to use some information I can attach to the menuitem in the backend. (like alias).

multiple aliase shouldnt be a problem because I use them as class