0

In my custom component, I have a sidebar with several entries. These are added using JHtmlSidebar::addEntry(...), as described in Joomla Documentation.

Most of these sidebar menu items will rarely be used by users. I want to group the different sidebar items. Or maybe add a menu heading in between some of them.

Is this at all possible? I can't find any info on this.

Any input is most welcome. Thanks!

1

JHtmlSidebar is pretty simple and doesn't support headings/separators or anything like that. But you can fake them by adding the required HTML to the language string used as a name for the entry and omitting the link.

The language string:

COM_MYCOMPONENT_SUBMENU_HEADING="<h3>My Heading</h3>"
COM_MYCOMPONENT_SUBMENU_SEPARATOR="<span class=\"class-for-separator\"></span>"

The addEntry() calls:

JHtmlSidebar::addEntry(
    JText::_('COM_MYCOMPONENT_SUBMENU_HEADING')
);

JHtmlSidebar::addEntry(
    JText::_('COM_MYCOMPONENT_SUBMENU_SEPARATOR')
);

If you want more control over the sidebar layout, you can create an override of joomla.sidebars.submenu layout specifically for your component.

Finally, you don't even have to use JHtmlSidebar to create a sidebar for your component.

  • Thanks @Sharky! That works perfectly. :) – TVBZ Feb 27 '20 at 12:56
  • Just out of curiosity.. How would you add the sidebar without using JHtmlSidebar? – TVBZ Feb 27 '20 at 12:56
  • Any way you want. It's just a list of links. – Sharky Feb 27 '20 at 17:34

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.