However, you can also show modules in the backend. The quick icons, site information, latest articles and logged in users are all examples of this type of module.
I'm going to show you how to build a custom administrator module to show important information to your site's administrators.
Step #1. Create the XML file
Create a file named mod_yourmodulename.xml.
In my example I'm going to use mod_admincustom.xml - that will work as the manifest file to list the extension details such as name, author, copyright, version, etc.
Use the code below as base for replacing the data with your own values:
- name - Use the same from your filename in this format: mod_yourmodulename
- author
- creationDate
- copyright
- authorEmail
- authorUrl
- version
- description
<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="3.1" client="administrator" method="upgrade">
<name>mod_admincustom</name>
<author>Your Name Goes Here</author>
<creationDate>December 2015</creationDate>
<copyright>Copyright (C) 2015 Your Brand Goes Here</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>This email address is being protected from spambots. You need JavaScript enabled to view it.</authorEmail>
<authorUrl>www.yoursite.any</authorUrl>
<version>1.0.0</version>
<description>Custom Module for Administrator</description>
<files>
<filename module="mod_admincustom">mod_admincustom.php</filename>
</files>
</extension>
Note, the module's name is repeated three times in name and filename tags. Be sure to replace it with your own custom name.
Step #2. Create the PHP file
Create a file named mod_yourmodulename.php - such as mod_admincustom.php
Use the code below to print the popular "Hello world!" phrase:
<?php
defined('_JEXEC') or die;
?>
<div class="btn-group viewsite">Hello world!</div>
This line ensure the code's file will be executed only through Joomla.
defined('_JEXEC') or die;
Step #3. Create the installer
Move the files from step 1 and 2 inside a folder with the name of your module. In this case, the name of the folder is "mod_admincustom".
Compress the folder as a zip file.
Step #4. Install the custom module
Install the zip file from the previous step as you would install any regular extension. Go to Extensions > Manage > Upload package file:
Step #5. Test the custom module
Let's display the module in one of the module positions of the backend template.
- Go to Extensions > Modules
- Set Filter to "Administrator", in order to manage modules for the backend.
The list of administrator modules are displayed immediately:
- Click the "New" button:
- Choose your custom module:
On the right side of the screen, choose a position such as status, cpanel, title, toolbar, etc. As I want to display my module in the footer, I selected the "status" position:
- Set module status as "Published".
- Click Save and close.
Step #6. End result
See the new module in action: