How to Add a Shortcut Icon to the Backend Menu in Joomla 2.5

One of our clients asked to add a shortcut icon to K2 in the top menu. As some might know, there’s a Joomla module that already does that, so we just downloaded that module and installed it and that was it! But we thought, what if such a module didn’t exist, or what if a client wanted to add a shortcut to a lesser known component that doesn’t have such a module already developed? So we decided to explain, in details, how to do that.

Now, before we begin, we want to explain two concepts:

  • You can add functionality to Joomla’s backend using administrator modules. Administrator modules work more or less the same way as site modules (which are the most common), but they only apply to admin templates.
  • Administrator templates are technically the same as site templates. In other words, they have what you call “positions”, which are placeholders to place modules.

So, how can one develop an administrator’s module in Joomla?

Well, it’s very easy. All one needs is to develop a simple, ordinary module, and, in the XML file, replace the following line:

<extension type="module" client="site" version="2.5" method="upgrade">

with this one:

<extension type="module" client="administrator" version="2.5" method="upgrade">

And that’s it!

So, the code for the shortcut_icon.xml file will be the following:

<?xml version="1.0" encoding="utf-8"?>
	<extension type="module" client="administrator" version="2.5" method="upgrade">
	<name>Shortcut Icon</name>
	<author>itoctopus</author>
	<creationDate>2012</creationDate>
	<copyright>Developed by itoctopus</copyright>
	<license>Free</license>
	<version>1</version>
	<description>This module displays a shortcut icon (to be used to link to your component of your choice)
in the backend to be placed next to the top menu.</description>
	<files>
		<filename module="shortcut_icon">shortcut_icon.php</filename>
		<filename>shortcut_icon.png</filename>
	</files>
</extension>

The PHP file (shortcut_icon.php) is as easy as the below:

<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
$rootURL = JURI::root();
echo '<a href="'.$rootURL.'/administrator/index.php?option=com_[your_component]"><img src="modules/mod_shortcut_icon/shortcut_icon.png" border="0"/></a>';
?>

Now all one needs is to choose a png image, rename it to shortcut_icon.png, pack all 3 files (shortcut_icon.xml, shortcut_icon.php, and shortcut_icon.png) into one file, called shortcut_icon.zip, and finally load that file into Joomla’s Extension Manager (which will effectively install the module).

How to make the shortcut icon module display next to the top menu?

This is the easy part. First go to Extensions -> Module Manager and then choose Administrator instead of Site from the first dropdown. This will list all the backend modules. Now search for shortcut_icon next to Filter and you’ll see the module that you’ve just installed. Now click on the name of that module, choose menu as position, publish the module, and then save it. Now you will the shortcut icon appearing next to your backend’s menu (on the top). Easy, huh?

As you can see, the process is not that hard, but it requires some programming skills as well as some technical Joomla knowledge (although we did our best to simplify everything!). So, in case you want to do the above and you feel that it’s a bit over your head, then fear not, all you need to is to contact us and we’ll do it for you in no time. By the way, you don’t have to worry about our prices, they are very affordable!

No comments yet.

Leave a comment