Doing More with Modules in Joomla 1.5

Technology Intersection Blog
Doing More with Modules in Joomla 1.5 Print E-mail
Written by Bruce R. Copeland   
Monday, 16 February 2009 14:50

Modules can help solve a wide range of problems in a web site that uses Joomla, but many Joomla site designers do not really know how to fully utilize modules. Eight months ago when I began designing the CyberSym Blogs site, I had some definite ideas about what I wanted. At that time I was fairly new to Joomla, and Joomla has a rather long and steep learning curve. Nevertheless after one somewhat false start, I managed to come up with a reasonably straightforward Joomla 1.5 design for the site.

A few things have however been headaches. The default Joomla 1.5 Syndication module doesn't allow customization to give any feed URI besides the root web site address, and a multi-blog site needs to have different blog feed addresses for different blog sections of the site. Moreover the CyberSym Blogs use burned feed URIs (e.g. http://feeds2.feedburner.com/tech-intersection ) which are different from the blog web site addresses.

As it turns out, each separate blog section on the CyberSym Blogs site has its own template. A lot of Joomla geeks would therefore simply suggest hard coding the necessary link into the <head> section of each template. So for Technology Intersection, the template index.php file would contain

<link href="http://feeds2.feedburner.com/tech-intersection" title="Technology Intersection Blog" rel="alternate" type="application/rss+xml" />

somewhere between <head> and </head>. This works, but suppose I don't want the link (or some other code) showing up on every page of the section? It happens I also spend a fair amount of time posting comments on other people's blogs. This is good blog practice, but only if you can establish a recognizable presence on other sites which points back to your own blog (branding). A really good way to achieve this is to use your own blog site as a provider link for OpenID (see e.g. Sam Ruby's "OpenID for non-SuperUsers"). To accomplish this I need to have OpenID server and delegate links in the <head> section on the main page of certain blogs. I do not want those links on all the other blog pages of each blog section. So how to do this? Joomla Modules, of course!

Modules are central to Joomla. Each menu has a module; there is a login module; there is a module for most popular articles, etc. Part of the power is that you can configure each module to work or show up on only those pages you want. Most of the time you position these modules somewhere visible on your page(s) by choosing from one of the roughly 6-20 locations predefined for whatever template(s) you are using (e.g. TOP, LEFT, USER3, etc).

There are many different kinds of modules in Joomla core and you can install additional modules as part of various Joomla extensions. To see all the module possibilities you have currently, go to Extensions/Module Manager in your Joomla administrative backend and select New. You will see a list of all the different kinds of modules. If you know how to write html or javascript (or if Google or some other site has provided you with script for a widget or a service), the Custom HTML module is especially powerful. You can select a new Custom HTML module, give it a name(title), select a Position from the list, use the Menu Assignment to specify the page(s) where the module will be used, enter whatever html code or javascript code you need in the Custom Output at the bottom, and then save it. The box with the feed button and different chicklets on the right of this blog's articles was done this way. [By the way, some editors available for Joomla do not play nicely with script that you may include in your html. An effective way to handle this problem is to create a new administrative login that has no assigned editor and use that login whenever manipulating script in a module.]

Some of you may not realize it is possible to define and use new module positions. Want a banner at the top of your blog article area? Find a line like <jdoc:include type="component" /> in the <container> section of the index.php file for your template, and insert a new line

<jdoc:include type="modules" name="componentbanner" style="xhtml" />

just before it. Next go to the Module Manager in your Joomla backend and create a new Custom HTML module. In the combo box for Position, type in a new position called componentbanner. Put the code for your banner in the Custom Output window. Now you have a banner in your new COMPONENTBANNER module position. This is all you need to do for templates you are using yourself. However to save headaches down the road, it is a good idea to put a line

<position>componentbanner</position>

somewhere below <positions> in the templateDetails.xml file for your template.

This approach is not limited to visible positions on your pages. Herein lies the solution to my feed and OpenID links problem mentioned earlier. In the <head> section of the template index.php file for each of my blog sections, I put a line:

<jdoc:include type="modules" name="pagehead">

(Because the <head> section doesn't contain visible layout, the added line doesn't include style="xhtml" the way it does for a new module position in the visible part of a template.) I then created Custom HTML modules positioned at PAGEHEAD which have the appropriate code for the feed for each blog section. I also created different modules for each of my OpenIDs that have the appropriate OpenID server and delegate code. These OpenID modules also appear at module position PAGEHEAD but only on the specific pages I want to use as OpenID links.

There are myriad other variations on where and how you can use Joomla modules. You can even get modules into your articles (see How to include modules in content item for Joomla 1.5.x). Maybe these ideas will help you solve some of your own site design headaches.

 
Comments (2) Comments are closed
opinion
1 Friday, 09 October 2009 01:59
Hi! I'm trying to learn more about Joomla - never dealt with it and now need it for my work. Hope your article will help me as well. Could you please recommend some more resources, where I can read about Joomla in detail without unnesecarry difficulties?
Re: opinion
2 Friday, 09 October 2009 07:59
Joomla, though powerful, tends to have a long and somewhat steep learning curve. Of course, previous knowledge of web design, CSS, HTML, and web security help a lot. The documentation on the http://www.Joomla.org site has improved quite a bit in the last few months. You can also turn up a fair number of useful articles by doing a Google search for "getting started with Joomla". Nothing however substitutes for setting up a test Joomla installation (with all the examples). This is the best way to get familiar with Joomla site menu structure, content structure, Joomla templates, and built-in Joomla modules.

It is still difficult to find useful information about Joomla security. There is a security checklist on one of the Joomla forum sites. Unfortunately much of the info in the checklist is fairly obvious if you already understand web security and meaningless if you don't. My best single piece of advice is to set the permissions on the configuration.php file in the root directory of any Joomla site so that the file is not publicly readable/accessible. This file contains the username and password for your Joomla database. Likewise make sure you never leave a site archive accessible/readable by the public.