Joomla! 2.5 Toolbar Popup Link Icon

Today I needed to add a new toolbar button to a custom Joomla! component. In the past, I’ve used a more convoluted method of overriding the submitbutton() (or Joomla.submitbutton) JavaScript function and triggering the modal popup manually, but stumbled upon a better solution.

Instead of using the JToolBarHelper class to add a custom button, I used JToolBar:

$bar =& JToolBar::getInstance('toolbar');
$icon_image = 'myicon.png';
$alt_text = 'My Label';
$page_url = JFilterOutput::ampReplace(
$width = 600;
$height = 400;
'Popup', $icon_image, $alt_text, $page_url, $width, $height

…of course switching in actual values for the variables. Since it opens an iframe popup menu, add tmpl=component in the $page_url variable so it omits the top navigation and whatnot. Also, note that I’m using JFilterOutput::ampReplace to convert & to & since appendButton doesn’t do that part for you.

The info was gleaned mostly from here:

One Response to Joomla! 2.5 Toolbar Popup Link Icon

  1. murugan r says:

    this is my requirement->1.when super user logins he should get all icons in the control panel and 2.when application administrator(say x) logins he should get only user manager icon in the control panel.
    pls help me

Leave a Reply