Category Archives: Joomla Tutorials

This category contains tutorials for Joomla! websites.

Getting Rid of Joomla! Comment Spammers

I recently downloaded and installed on my Joomla!-based web site ( a Joomla! comment component that allows visitors to my site to make comments on articles I’ve posted.  The component even comes with an image verification code to keep automated spider spammers from going through my site and leaving their annoying trail of links to suspicious websites.  However, precautions be danged, the spammers still came.  Soon after I installed the comment component, I found that spam comments, presumably entered manually, were showing up on many of my site’s articles.

When I checked into how these spammers were finding me, I noticed that they were using Google searches for terminology used in the comments section.  Most specifically, they were searching for the term “powered by !joomlacomment“, which is found at the bottom of each articles where the component shows up.

To remedy the situation, I performed a Linux search from the components/com_comment/ directory for the file containing “Powered by !joomlacomment” by executing this Linux file search command:  find . | xargs grep ‘Poweredsl”.  The result showed me that the guilty section of code was in the insertPoweredBy() function located in the components/com_comment/joscomment/comment.class.php file.  I removed changed the return statement in that function to simply “return ‘’;  That should make it so that those irritating spammers won’t be able to find me so easily.  I may end up having to change other wording or the layout of the comment section to keep them away from my site.

In addition to making it more difficult for spammers to find my site, I also set the Autopublish comments setting to No.  That setting is located under the Security tab of the !Joomlacontent ->Content Settings page.  With that setting in place, at least the spammer comments won’t show up on my site automatically.

I hope this article is helpful for any of you who might need a little extra help staying ahead of that group of society intent on wrecking havoc on the Internet world.


Using Google Analytics with Joomla!

Google Analytics is an indispensable tool for webmasters.  Joomla! is a very popular content management system.  It makes perfect sense for Joomla! to have a method of integrating the Google Analytics reporting tool into its framework.  Using Joomla!’s template system, administrators can insert the necessary script for the Analytics system to track visitors to each page contained on the site.

Here’s how it works.  To use Google Analytics, you have to set up an account through Google.  You can access Analytics by going to  After setting up an account, you are given a block of JavaScript code that you’re supposed to include on each page of your website – at least those for which you want to track traffic.

Once you’ve obtained the Analytics script from Google, you need to paste it into your current Joomla! setup.  To do so, access your currently active Joomla! template by going to Extensions->Template Manager. 

From the Template Manager page, click on the name of the currently active template.  The currently active template is marked by a star icon in the Default field. 

Next, click on the Edit HTML icon.  Doing so will take you to a screen that will allow you to edit your template’s index.php file.  Each time someone visits a Joomla!-based website, the page request is directed through the index.php file for the active template, so that’s the file you need to edit.

Once you’ve pulled up the index.php file for your Joomla! site’s active template, you need to paste the Analytics script in a place where it won’t interrupt other parts of the code.  I typically place mine just before the closing body tag, as shown below.  Many webmasters prefer to put the code in the header section of their template’s index.php file.  As long as you place the code where it doesn’t interfere with other sections of the page, you’ll be fine.

One important thing to note with regard to Joomla! templates is that more than one template file can be used on a website at a time.  For instance, you may have assigned an alternate theme to articles pages in a particular category of your Joomla! site.  For this reason, it’s a good habit to go ahead and put the Google Analytics script in the index.php file for each of the templates you have installed, even if you don’t currently have pages assigned to use any template other than the default.  If you later install another Joomla! template, you should go ahead and put the Analytics script in that one as well.  If you don’t have the script in each of your template files, your Analytics stats won’t account for visitors who might come to one of the pages on your site on which the tracking code does not exist.

Building a Joomla Component – Setting Up the Basic Structure


Setting up the Directory Structure

The first step in building a Joomla! component is to set up the basic directory structure and files to support it.  There is a /components directory located in the root Joomla installation folder.  This folder contains files and other folders pertaining to the front end (what web site visitors see) of your component.  Also located in the root folder of your Joomla! installation is a folder setup like this: /administrator/components.  This is the folder where your back end administration files and folders go.  The naming convention used for the folder where a Joomla! component actually exists is com_mycomponent, where mycomponent is the name of the component.


When the component is called from the backend or from the front end, the Joomla framework automatically looks for a unique .php file named after the component.  An example will help illustrate this setup:


If I were developing a mortgage calculator (mortcalc), I would use the following directory setup




Registering Your Component in the Joomla! Database

To create access to your component from the Joomla! administrator navigation menus, you need to register the component in the Joomla database.  This is done by making an entry in the jos_components table.  If you setup your Joomla! database so that it uses a table prefix other than jos_, your components table name will obviously be slightly different.  The pertinent fields from that table, which you’ll need to specify when making your component entry, are name, link, admin_menu_link, and option.  These fields set up the Joomla! internal navigation for your component so that it can be referenced from the Components menu and so that it can be linked to on the frontend from a Joomla! menu using the standard component link.


After you have executed the SQL (either with an SQL statement or using a graphical interface) to register your component, you will then see it listed under the Components menu of the Joomla! administrator section.  The value you entered in the name field will be the name that shows up on the Components menu.


Moving Forward
With these two steps behind you, all that’s left to do is code the functionality of your Joomla! component, right?  Obviously there is a lot of work ahead now that you’ve set up the basic structure.  To make the most of your component and the Joomla! extension framework, you should familiarize yourself with the Joomla! extension classes.  Joomla! provides class structures and a development framework that simplify performing such tasks as creating toolbars, handling the logic between your database, the administrator setup, and providing a useful experience for end users of your component.