Create a Custom Joomla 2.5 Module
Lesson 1 of 3 · Create a Custom Joomla 2.5 Module - Part 1 · IT & Software
About this course
hey guys in this tutorial I'm gonna be showing you how to program a custom joomla 2.5 module now i'm making this video because i realized that there
isn't too much on the subject it's really hard to find a good tutorial to develop any kind of joomla components or modules or even plug-ins so what i want to show you how to do is build a module
that will grab all the featured articles from it from the database and post them in a module position and it will be able to show the title as well as the intro text and we're going to give it some
parameters so that you can choose for instance how many words you want the intro text to put out so yeah so the first thing we're going to do is create the stuff file and folder structure so
you want to create a new folder and you're gonna call this mod featured articles that's going to be the name of the module and in that folder you want to create a few files first of all we
want to create in index.html file next we want a a mod featured a mod featured articles dot XML file and this is where I will put all the information about the module next we want a mod well
we want a mod featured articles dot PHP file which is the entry point of the module and we want to help her helper PHP file which you don't need if we were making an extremely simple sample module
just to display some text or something we wouldn't need the help her and we wouldn't need to plus some of these other files that we're going to create but this is gonna be a pretty
intermediate tutorial so in the next file is one that we don't need it's one that I just like to have just extra functions functions PHP you won't see that in a lot in most modules but I just
like to have it just for certain functions and then we want to create a new folder and that's going to be the template folder which will be TM PL and in that folder we want to create a file
called default PHP we're only gonna have one one layout for this module if you're gonna have more we could add we could add them here and we also just want to add that index.html file
and these index.html files don't really do anything as aside from not letting people access that the directory because when you access a folder on the internet it looks for either index.html or
index.php if we didn't have this here then they would be able to see the file structure depending on what kind of server you're running it on so that's what those are and we actually show you
the content we put in there we just want to have some tags well I don't want to open it with a browser I want to open it I'll just open it with notepad plus plus and all we
need is just the HTML and body tags so just save that and close all these up and now going to the other index.html file and put the same thing okay so now what I usually would do next is create
the XML file so here what I'm going to do is just copy and paste that the content in and I'll explain it and I'll try to go over at all so you can I mean if you want to go along can
pause the video so we just have an XML opener here and then we have this extension tag and in this extension tag it says what type of extension it is which is a model I'm come on a module
and then the version of Joomla which is 2.5 and then we have this this is for the site part it's not an admin model mod module and then the method I put upgrade you could put install here the
reason I put upgrade is that you if you already have a version of this installed and then say this is updated to version 1.1 you'll be able to just install it right over the old version so I always
use upgrade here and then some just simple meta information named author creation date copyright license your email authors the URL the version of the actual module which for this one is 1.0
a description this is the description that that comes up after you install it and then we have the files tag which has file name tags that include all that every file and folder that you have in
this module which which shows us the ones all the one that we just created the main entry point is mod features that featured articles dot PHP so you just have to have this argument here I'm
just showing you that that's the entry point and then this config tag holds all out fields in field sets so you want to have this fields tagged with the name params
and then the field set is basic for the next few parameters and what this is is when you go into module manager and you click on a module all the options that show on the right-hand side that's what
these are going to be we have one for the count for the for the number of featured articles we want to show okay it's a type of text so it's just a text box next we have a show text parameter
and this is just going to be a boolean it's gonna be either 1 or 0 no or yes it's just going to tell us it lets us tell them if the intro text will be shown or not so if it's that no then
it's just going to show the title no intro text the next one we have is a word limit this is just how many words will display for the intro text the default is 25 and that's just a type of
text as well she'll read more another boolean parameter that'll tell it if we want to show a link that says read more or if we want to just leave the title as the link and then we have a new field
set of advanced which will be below the basic and all we have here is the module class suffix and this is just you can add a class that'll be tagged on to to the modules code and then you could
style it separately and then you close up the fields and field set and that should that should do that should work for us so I'm going to save that now
the next thing I want to do is open the entry point file mod featured articles dot PHP so here I'm actually gonna copy I'm gonna copy the code and paste it in so here we have some opening comments
just the name of the module and the file this is GNU GPL license it's all open-source feel free to use it and we have this line here this je exact line hi and what this does is it makes it so
people can't access the file directly they have to go through through the Joomla site and pretty much all files in Joomla have this next what we're doing is including the helpers
we're actually including from the components folder of the Joomla site and the content helpers in the route because what this is actually doing is grabbing the featured articles through the comp
the content component which is called com content so it's including that that helpers in the row and here's the params this is where we grab the params I just showed you if we go back to the XML file
you'll see we have this command called arc count which is the number of articles to show in that actually that's not here this pretext should be here actually
so show text if we go to the XML we have this show text and the name is what's important here because that's what you're going to use here because we can actually get it through this params get
show text just like this params get word limit we get in from right here and what we're doing is we're just putting those into single variables here so we can reuse these next we're including that
functions PHP file that we created and then we're including that helper dot PHP file which is where all our data base a lot database logic will go down and then we have this rows we're assigning this
function this get rose from the helper we're signing that to a variable called rose okay so the Rose will hold all the featured article info and then we're requiring this is where we define our
layout by default we're gonna have it have show the default which is this default dot PHP file so we're basically including it here so that's the the gist of this of the entry point file
so I don't want the video to get too long so I'm actually going to continue this in the next part so try to get this done in two or three videos