5

I've started developing my first ever component and an using Joomla's JSubMenuHelper class to add a sub-menu to define the different views, like so:

public static function addSubmenu($submenu) 
{
    JSubMenuHelper::addEntry(
        JText::_('COM_SHOUTBOX_SUBMENU_SHOUTS'),
        'index.php?option=com_shoutbox',
        $submenu == 'shouts'
    );
}

This works perfectly fine and output the following:

enter image description here

However, I would like to add an icon before the string like Kunena have done. (See below image)

enter image description here

Kunena have manually constructed their menu which I could do too, however I would prefer to stick to using Joomla's addEntry method.

So my question is, how can I add an icon to each menu item?

4

You can use the first parameter of addEntry() for that, for example:

public static function addSubmenu($submenu) 
{
    JSubMenuHelper::addEntry(
        '<i class="icon-home"></i>' . JText::_('COM_SHOUTBOX_SUBMENU_SHOUTS'),
        'index.php?option=com_shoutbox',
        $submenu == 'shouts'
    );
}

This would add the home icon to your menu label. You can see a list of icons that come with the An overview of all icons shipped with the Isis template can be found here: http://kyleledbetter.com/jui/icons/

addEntry documentation: https://api.joomla.org/cms-3/classes/JHtmlSidebar.html#method_addEntry

  • Not sure why I didn't think if this initially :/ Thanks fruppel, much appreciated :) – Lodder Mar 23 '15 at 14:36

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.