Your go-to resource for Joomla knowledge, tutorial, information and latest news in Joomla world

Customize Joomla Extensions With Override


We all know that Joomla is a fantastic CMS for building professional websites. The JED (Joomla Extension Directory) is full of components, modules, and plugins that can add almost any type of functionality to any Joomla site. That's great and all but what if you find a component or module that gives the functionality needed but the output and layout are not exactly what you want? A big mistake that some developers and webmasters make is going in and editing the core code of an extension. Joomla makes it easy by allowing overrides.

What is an Override?

An override is a copy of an extensions layout/template file that is placed in your Joomla template directory. You can then customize it to your liking. The difference with doing this as opposed to just editing the file in the extension directory is that when you upgrade Joomla or the extension, your changes will not be replaced with the new versions. Joomla knows to look in the overridden file first, then the actual extensions file.

How do I Create an Override?

Creating an override is easy. For the sake of this tutorial, let's say that we want to edit the output of the login page. By default, the login page has 3 links in an unordered list (forgot password, forgot username and don't have an account).

Default component frontend


For the sake of this tutorial, let's say that we do not want the last "Don't have an account" link and we also do not want them in a list, we just want the 2 other links side by side. The changes we make do not really matter at this point. It is just to show you how an override works. By default, Joomla uses the com_users component to handle login and registration. The com_users component has multiple views/layouts. We can see them by going to joomlasite/components/com_users/views

Component view files


You can see there are 5 different views. We want to edit the login page so we want the login folder/view. If you click on that, you will then see a tmpl folder. This is the template for this particular view. In the tmpl folder is where the layout files are located. Just about all component and module tmpl folders have a default.php file. Some components such as this have additional template files. The Users component login view has default.php, default_login.php and default_logout.php.

Component layout files


The default_login.php folder is the one we need to edit the login form page. So we need to take that file and place it into the Joomla template folder structure. Go to your main Joomla template folder. This would be in joomlasite/templates/yourtemplatname. You need to create a new folder called html. In that html folder, create another called com_users and then in that, one more folder called login. This is where you want to place the default_login.php file that you copied. So the full path would be joomlasite/templates/yourtemplatename/html/com_users/login/default_login.php

Editing the default_login.php File

So now if we make some changes and save the default_login.php override file, Joomla will look to this file first. Let's make the small change of removing the list and the last link In the new default_login.php file, you will see the following code

Default component code


It is the unordered list with the 3 links. Let's edit this by removing the list tags and getting rid of the 3rd link along with the if statement. So it will look like this

New component frontend


Now save the file and go back to your frontend login page.

New component frontend


You can now see that the list formatting and the 3rd link are both gone. So now if you update Joomla core files or update the com_users component, this change would stay with the site as oppose to just being written over. This is extremely useful in Joomla web development. You can do this with any component or module that follows the standard Joomla structure. Do you have any extensions in mind that you would like to tweak to your liking? Let us know in the comment section

JSN Template Framework - Things behind the scenes
Joomla! 2.5 Form, what are the 5 best extensions?

Getting Started Series

Step-by-step guide to build quality website with JSN Template

Learn More