1

I have the following Menu Structure

Books [/books]
    New Books [/books/new-books]
        Fiction [/books/new-books/fiction]
        Sci Fi[/books/new-books/sci-fi]

The Books Menu has Books (the Menu itself) as the first level, New books as the second level and Fiction and Sci Fi as the third level.

What I am trying to achieve is the following. Essentially the url structure for the 'Sci Fi' Menu Item remains the same but visually, it sits under Fiction.

Books [/books]
    New Books [/books/new-books]
        Fiction [/books/new-books/fiction]
            Sci Fi[/books/new-books/sci-fi]

There were two ways I thought I might (a big might at that) be able to achieve this but both seems like a very 'ugly' way to go about doing it but I can't think of any other way I could achieve this.

Method 1: Created a content plugin to which will check a pre-defined class name on the of the menu list item -> get the parent li -> remove all such menu items and put it under another predefined parent item.

Method 2: Using jQuery get all the list items with a defined class (in the jsfiddle "fourth-menu"), remove it from their existing position and add it to the pre-defined parent (using class/id on the menu item href).

As I mentioned before both method sounds very convoluated so I was wondering if there was a better way to achieve this?

I have created a jsfiddle which makes it a bit more clear as to what I am trying to achieve.

2

You can always use template overrides to achieve an altered rendering, mod_menu is no exception. But a better way might be the use of Menu Item Aliases. You can find this menu item type under "System Links" if you create or modify a menu item.

A Menu Item Alias will use the URL of its target menu item. A possible structure could look like the following example:

Basic Menu, which may or may not be displayed:
- RealA (type: any) => /a
- - RealB (type: any) => /a/b
- - RealC (type: any) => /a/c

Special Menu, which will be displayed through mod_menu
- AliasC (type: alias, target: Realc) => /a/c
- - AliasA (type: alias, target: RealA) => /a
- AliasB (type: alias, target: RealB) => /a/b
  • I tried doing a test but all I see in the Module output is the level 1 Item [RealA or Books in the example I used]. I have attached the relevant screenshots showing I followed what you mentioned but maybe I am missing something here but it just won't show up. The only way the menu items show up is if I say 'Yes' to Show all Menu Items all the time. – sifu Mar 11 '15 at 1:40
  • That's how Joomla works. Unfortunately there is no workaround to alter the behavior (you could fork mod_menu). An alternative might be to use "Show all Menu Items" and hide items via CSS, as even aliases should have the right "active"-class. – Nils Rückmann Mar 11 '15 at 2:59
  • Will give a try. I have an idea where I think I will try to add a custom field in the Menu Item ('Display Under') and allow the editors to select the 'visual parent' item. Will update the post to see if I have any luck. – sifu Mar 12 '15 at 23:22
  • 1
    Maybe this could work: github.com/nueckman/joomla-ex-menuaddition – Nils Rückmann Mar 13 '15 at 16:44
  • Thanks Nils. Will give it a whirl this weekend and inform how it goes. – sifu Mar 13 '15 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.