Joomla! Tutorial – Adding New Positions

For some reason, this was a very difficult task for me to learn. Try as I might, I couldn’t seem to find the right words to search to find the answer to this question. After (literally) a few hours searching the Joomla.org forums, I finally cracked the case. So hours of searching led to about 2 minutes of work (if you include uploading), and I had more UserX positions then I could ever use.

So here’s the deal: Templates come with a variety of positions, all depending on what the designer had in mind for the template. Usual ones include Search, Left, Right, Breadcrumbs, some number of UserX, and a variety of others. In the module manager, you can see what position each module is in, and if you edit the details, you can change the position in the details box, using the drop-down menu. They have disguised it by labeling it “Position:” As you likely know, once you’ve assigned the position you can adjust where each module appears in that position by changing the order number on the module manager screen.

Okay, that’s all well and fine, but what happens if you want to put a module in a place where there is no proper position? For example, you are going to make a module of custom html that calls one of your gCal calendars to show the upcoming events for your hat-knitting club, and you want it to display on the right side of your header space. You are going to want a userX position for it, but you have already used up the two user positions that came with your template (lazy designer…..). User1 is your latest news module and User2 is your log-in form, both positioned under your body content, above your footer. You clearly need a User3, but there just isn’t one. Yes, you could re-purpose the Search position, but you could also simply create more users positions. And the good news is, it’s ridiculously easy.

Get into your Joomla! install how ever you like (Dreamweaver is my choice, but simple ftp is fine, or even a web interface with your server-provider). Open /root/templates/{whatever template you are using}/templateDetails.xml. If you have never opened an XML file before, breathe, it’s okay. They look more intimidating then they actually are. The file itself can vary, depending on who made the template, but it should include things like the version, the author, their email, website etc., and some other basic stuff. There is also be a listing of the files/folders that accompany the template. Then we hit the main course (for the sake of this tutorial). There is a tag called <positions> which is followed by a series of tags called <position>. You will likely see what is happening here. Between the <position> tags are the names of all the positions that template has, Top, Newsflash, Search, User1, User2, etc. So all you have to do is start adding <position> tags with new names in them. <position>User3</position> is a good start for our scenario, but it could just as easily be <position>MyLeftFoot</position> or <position>Beer</position>, for all Joomla! cares. Add as many new positions as you want. Add more then you think you will need (but don’t get silly). Save the file, upload it, and go check your custom html module. You should be able to assign it to “calendar” (if that’s what you named a position), or User3, or MyLeftFoot.

Here is where some people have gone astray in the past. That new position only just came into existence. The template designer certainly has never heard of it, so you can bet that it doesn’t show up anywhere in your template’s index.php file. So that is your next stop. Open up your index.php, and insert a call for the module where ever you want to place it (if you are newer to working with html, Firebug for Firefox could help you figure out where in the code you want to put the call). The call will look like this:

<jdoc:include type=”modules” name=”PositionName” />

It might be helpful to look at other examples of that tag in your index.php, to see how they have been placed within <div>s, and also how they have been styled. Once you have added it, save and upload, and check your results. Hopefully you will see your gCal (or whatever) right where you want it. If not, do not fear. Tweaking stuff like this is the fun part of working in web development, right?

This entry was posted in Joomla!, Software, Templates, Tutorials. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 
  • Follow Me

    FaceBook Twitter LinkedIn
  • Join My Mailing List

    Powered by MailChimp