In this exercise we will use the Protostar template, which is native to Joomla, and the Content Component (com_content), but you can use other templates in a similar fashion.
Let's start by creating an override.
- Create a module override in the administrator.
- Go to Extensions> Templates > Templates
- Click on Protostar Details and Files
- Click on the Create Overrides tab.
- In the Modules column, click mod_login
- At this point you will be taken back to Editor tab
- A new html folder has been created. Inside it, there is a copy of the mod_login files that can be edited.
Changes made to files inside the html folder will affect the entire site. The original module files in Joomla will be overriden. When a Joomla update is released, changes made to these files will not be lost.
Creating an Alternative Layout
A module Alternative Layout allows users to have more control on creating changes to the layout and where these changes will be applied.
- Copy the default.php file and rename it to newlayout.php. The filename can not contain spaces, underscores (_), or hyphen (-).
- Open newlayout.php in the code editor
- Go to the last line of this file where there is a </form> tag.
- Create a new line before this tag and paste the following HTML: <p>This is an alternative layout.</p>
- Click Save & Close.
Enabling the Alternative Layout
Now it is time to put the module aternative layout we created in action.
- Go to Extensions> Modules
- Create an instance of the Login module.
- On the Advanced tab, in the Layout field, the name of the new alternative layout is displayed.
- Select it.
- On the Menu Assignment tab, select On all pages.
- Save and close.
- Create a second instance of the Login module.
- On the Menu Assignment tab, select On all pages except those selected
- Check the Home Page box
- Save and close.
- Go to your website and test the module.
If all is OK, you will see the text This is an alternative layout at the bottom of the module on the home page only.
If you have any questions or suggestions, please write in the comments below.