Custom Admin Quickicon in Joomla! 2.5

I recently had to dig up how to add a custom admin Quickicon (the icon links on the left side of the Administrator section’s control panel) in Joomla 2.5. In previous versions, I’d just built a custom admin module for each icon. Now, there seems to be a somewhat easier way.Adding an icon to the main list is a bit less straightforward. If you look in the default module:

/administrator/modules/mod_quickicon

…you’ll see that the whole list is being generated and wrapped in a div with class=”cpanel”. What we want to do is add our own custom icon to the list before this happens. In the helper.php file, see the modQuickIconHelper::getButtons() method for details.

Instead of creating a new admin module, we need to build a custom plug-in that adds additional icons to that list before it is output. Joomla is already doing this in recent versions, and you can find examples here:

/plugins/quickicon

Chances are, these examples are more complicated than you need since they’re using Ajax to check the version/update status of Joomla or your installed extensions. Here is a simplified example plugin:

Download mycustomicon.zip Example Plugin »

Inside the zip archive, see the main plugin file “mycustomicon.php”:

<?php defined('_JEXEC') or die;

class plgQuickiconMycustomicon extends JPlugin
{
    public function onGetIcons($context)
    {
        if (
            $context == $this->params->get('context', 'mod_quickicon')
        ){
            return array(array(
                'link' => 'index.php?option=com_content',
                'image' => 'header/icon-48-component.png',
                'text' => 'Quickicon Example',
                'id' => 'plg_quickicon_mycustomicon'
            ));
        } else return;
    }
}

We’re hooking to the onGetIcons event, and:

  • Check the context and permissions (lines 7 – 9)
  • Add our own icon to the list (lines 11 – 16)
  • Return null

The “id” value will need to be unique for each icon. For the “image” value, use the relative path from:

/administrator/templates/bluestork/images

(or whichever admin template you’re using). If you’d like to use a custom icon image, enter the absolute path to that image, including “http://” …my first guess was that I could just start the path with a / and Joomla would know that the image path was absolute, but that did not appear to work without the fully qualified http:// address.

See Joomla’s update icons for better examples that make use of language files and what-not.

33 Responses to Custom Admin Quickicon in Joomla! 2.5

  1. Hofit says:

    Hi,

    How can I use this plugin multiple times?

    Thanks

  2. Nate says:

    Hi, Hofit. It’s more of a basic template for building your own plugin – if you need more than one, you’d need to change the plugin and file names to something unique. For instance, change the folder “mycustomicon” name and the mycustomicon.php and mycustomicon.xml file names to, for instance, mycustomicon2. Then, do a find/replace in the .php and .xml files for the same “mycustomicon” to “mycustomicon2″. Then, re-compress the folder to a zip archive and install. Does it work then?

    I may add a little form for auto-building a custom quickicon plugin and add to this site… would be nice to have, at least for my own use. If it happens soon, I’ll post an update here.

  3. Hofit says:

    Well, it doesn’t work since it doesn’t give me an access to the control panel anymore…

  4. Nate says:

    It works. If yours doesn’t, you’ll need to be more specific about any error messages, or paste in the code you’re using.

  5. hofit says:

    I did exactly what you told me to, changed everything to mycustomicon2
    I couldn’t access the control panel, it gave me a blank page with no errors

  6. Nate says:

    That usually means you have a PHP syntax error, and your server is set to not display errors on the screen. I’d just be guessing though without seeing your code. You’re welcome to paste it here or email to me as an attachment: support[at]mindpalette[dot]com

  7. Nate says:

    Also – first thing I’d check is the plugin class name. Make sure this line:
    class plgQuickiconMycustomicon extends JPlugin
    …got changed to:
    class plgQuickiconMycustomicon2 extends JPlugin

    Otherwise, it would throw a PHP syntax error when trying to re-declare another class of the same name. Just guessing though – I’d be happy to dig deeper if you send the code.

  8. hofit says:

    Yeah, that was it.. thank you! great plugin!

  9. Javier Lo Russo says:

    Hello ,sorry my english. I use your plug in for the VirtueMart component, and I can see the button if Im in mode Admin, but I cant see it if dont.
    I create a User Group call “Virtuemart” and the only denegate permission is “Super Administrador”.
    I dont know what I do wrong.
    Regards.
    Javier

  10. Nate says:

    Hi Javier. If it’s causing permission issues, you might try removing this line:
    && JFactory::getUser()->authorise(‘core.manage’, ‘com_content’)
    …which is probably not something I should have included anyway, since it’s specifically checking for admin permissions for the com_content component. If it’s not working right after that, can you email me the code you currently have? support[at]mindpalette[dot]com

  11. Nate says:

    Update: I’ve just removed the permissions check from the code above since it was specific to com_content – the icons should now show up for anyone with control panel access.

  12. Carlos says:

    Hi, how I can do to automatically upload the icon to the template administration’s folder in the xml plugin instalation?
    I need it because I want to distribute with my component.

    Thanks!

  13. Ben Clay says:

    Perfect – thanks!

  14. murugan r says:

    the control panel of my joomla administrator has two icons list and both lists contains same icons.i want remove one icon list…can anyone help me about this issue??????

  15. Nate says:

    Hello – if you have 2 sets of Quickicons in your admin control panel (and you’re using Joomla 2.5), try going to Extensions > Module Manager from the top menu. Then, in the first filter menu above the list, choose Administrator instead of Site. Do you have more than one Quick Icons module there in the “icon” position? Or, there are some custom admin icon extensions – is one of them installed and also activated?

    You can temporarily disable a Module in the Status column to see if you’ve found the interloper. If you’re using a different version of Joomla, the specifics may be different.

  16. murugan r says:

    actually my problem was 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-this is my requirement.
    what i did is i installed asikart quick icon plugin so that i managed application adminstrator(x)but i am facing follwing problems.
    1.two icon lists(quick icons and asikart quick icons list) is coming for both super user and application adminstrator.
    so i want to remove any one of that list (quick icons list or asikart quick icons list) from both super user and the administrator.
    please help me

  17. murugan r says:

    mr nate i will un uninstall asikart quick icons plugin.i already told my requirement that “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”.now i have only one quick icon list..now can u tell the procedure to meet my requirement?

  18. Nate says:

    For that sort of thing, I use permission settings (users, groups, access levels, etc.), and the existing admin Quickicons are smart enough to know which users to show which icons to. Here’s a good article about how to customize the admin stuff:
    http://magazine.joomla.org/issues/Issue-May-2012/item/761-Joomla-ACL-Configuring-back-end

    It’s fairly important to take this approach since you want to control more than just which icons to show – but also control which admin panels a user has access to, even if they already know the right admin URL. Controlling it via permissions generally takes care of both – icons and admin panels.

    I can’t go into detail right now on the specifics, but if you try it from the linked article and run into problems, you’re welcome to post back here and I’ll help if I can.

  19. murugan r says:

    thank u so much nate..i got it.

  20. murugan r says:

    nate i have one more requiremnt regarding email verification during registration of joomla.

  21. murugan r says:

    so my requirement is when person enters tcs mail id that person should move to the one user group and for other mail id’s it should move into the other user group.

  22. Nate says:

    In the past, when I’ve wanted to do something special with new user registration, I’ve build a custom component using Joomla’s com_users component as a guide, adding in my own processing to the controller and such.

    For something more simple like you’re needing, would probably make more sense to create a plug-in that uses the “onUserAfterSave” or “onUserBeforeSave” trigger to intercept the registration and/or edit form submissions and manipulate the user groups based on email. I don’t have the specifics since it’s not something I’ve yet done, but this page seems like a step in the right direction:
    http://docs.joomla.org/Plugin/Events/User#onUserBeforeSave

  23. murugan r says:

    since i am new to joomla can you be more specific about “onUserAfterSave” or “onUserBeforeSave”.i could not understand what tehy specified in that link.
    can we get “onUserAfterSave” or “onUserBeforeSave” readymade plug in????

  24. murugan r says:

    r else if u have any sample code for my requirement pls post here:)

  25. Nate says:

    Sorry, I can’t provide sample code or specifics at this time. If you are a PHP developer, then “onUserAfterSave” and “onUserBeforeSave” are event triggers that you can use when creating a custom Joomla plugin (to assign users to groups based on their email address). The best I can offer there would be a link to the documentation for plugin development, which seems incomplete:
    http://docs.joomla.org/Plugin_Development
    …or, I made use of the videos here when first learning the subject myself:
    http://www.lynda.com/Joomla-1-6-tutorials/Joomla-1-7-Programming-and-Packaging-Extensions/73654-2.html

    Otherwise, you might look in the JED for an existing user plugin that does what you need:
    http://extensions.joomla.org

    I’m not familiar enough with other extensions to make a specific recommendation, but you might have better luck on the Joomla forums:
    http://forum.joomla.org

    Good luck!

  26. murugan r says:

    ok nate leave that requirement.i have a new query saying that is it possible to display any of the control panel icons on the home page???

  27. murugan r says:

    if so pls provide the solution.

  28. murugan r says:

    mr nate forget about above questions and all here is my requirement-when we install components that should appear on the home page of the joomla 2.5. or else
    tell how to display already existing components(in the back end) on homepage in joomla 2.5..

  29. murugan r says:

    reply nate

  30. murugan r says:

    after successfull login for all new users same article(say welcome article) should appear instead of thiere profile details in my joomla 2.5. pls provide the solution

  31. murugan r says:

    wat i mean to say is once user get registered he is going to login know at tha time he should get one welcome message. but i am getting his profile discription.

  32. sajan says:

    i am struggling with the following requirement.

    my requirement is basically the volunteer list has three goups namely
    1.active voluneer list
    2.ready volunteer list
    3.passive volunteer list

    lets say there are 50 volunteers.out of 50 ten members are in active volunteer list and remaining 45 are in volunteer list .based on the date(say some 15 days period) active volunteer action will expire.
    out of 45, ten members already present in ready volunteer list so we need to inform this volunteers about expire date of members in the active volunteer list before one week because this members will have to move into the active volunteer list and perform there action as a active volunteers.
    finally if the members in the active volunteer list period gets over they automatically should move to the passive volunteer list.and the cycle repeats.
    i am new to joomla and i dont know how to start and that much coding.. just give the brief idea:)

    regards
    sajan

  33. Steven says:

    The plugin works great but, I have created a user that has no permission to see the icons from the quick_icon module although the edit profile icon shows, how can I force mycustomicon to show for all users like the edit profile icon?

Leave a Reply

Advertisements: