Modules are the quickest way of getting pieces of PHP code running and displaying on your Joomla site.We'll start by installing a module that has the bare minimum amount of PHP code necessary for Joomla to run.
Let's go to the backend of Joomla to install this module.Now, let's go to the Extension Manager to install the module.
Click on the choose file button, and from here, select the mod_noidacity.zip file from the download i have provided below.Click Upload & Install and the module gets installed.
However, we still need to publish it, so that it appears on the front-end. So let's go to the Module Manager.
Under "Know More About Noida City", we want to make sure that we select a position for the module.So, if you're using the beez_20 template, I recommend selecting position-7, and then we also need to make sure that the module is set to Published.So select Published as the Status.
Finally, we need to make sure that the module is appearing on all pages. So scroll down and select all pages as the Module Assignment. Click Save & Close, and then go back to the front-end and hit Refresh.
So now you'll notice that just underneath the Main menu, the "Know More About Noida City" module now appears along with the Module Content which is "Welcome to Noida City".
Let's take a look at the files that got installed when the module is installed, so that we see where this Module Content is coming from.
This is the root folder of Joomla and let's scroll down to the modules folder and then at the bottom is the mod_noidacity folder.
This is the folder that got installed when the Zip file was uploaded. You'll notice the index.html file and this is just a blank HTML file that's there to discourage Apache from displaying virtual directories, and then you'll notice the mod_noidacity.xml file.This is the first most important file that Joomla is going to look at when it attempts to install this module. Inside this file, there is a lot of identification information that tells Joomla what this module is, what it's about, who wrote it, and why you want it on your system.And all of that is included in these tags here at the top. Down here at the bottom is the files tag. Any of the files that you want to have installed with this module have to be listed here in the files section. The very first element here is the file name for the main module file that gets run when the module is displayed. You'll notice that there is an attribute of module="mod_noidacity" and this is important to note, because this tells Joomla that this is the file that you want to run when this module runs. Next, we have the other two files that are included in this package.
Finally, let's take a look at mod_noidacity.php.Inside this file, we have the opening PHP tag along with _JEXEC or die; and what this does is it makes sure that nobody can go to mod_noidacity.php directly without first going through Joomla Then underneath that, we have a simple echo statement"Welcome to Noida City" which is for writing the content that is within the module.
- echo "Welcome to Noida City";
Note here that you could use whatever PHP code you want.You could make calls to the database here, you could go to a third-party web service. You could do any PHP code that's valid in PHP and just echo the output right here. Modules are the most straightforward type of Joomla extensions you can build. With the minimal amount of code, you can start a module and build it out to suit your needs.