Skip to main content

Welcome to Geoff Hayward's Weblog

Commenting on Java, JavaFX, Java EE, Joomla, and IoT.

We humans recognize a 404 error as a page not found. That is helpful nevertheless the foremost reason of a 404 error code is to let the requesting computer know that the page was not found. Most of the online Joomla 404 error tutorials are missing the point and giving developers a method that is returning a 200 OK code.

Here is How to Set up a 404 with Joomla

First, create an article. The name of the article would benefit from being called 'Page Not Found' or something similar. Within the article's content tell your users what went wrong. Hit save and make a note of the article's ID number.

Then FTP into your theme folder's root and add a new file called 'error.php'. The 'error.php' file is an override that is called by Joomla automatically if a requested webpage cannot be found. Once you have added the 'error.php' page, paste in the first template you can find below. Swap out the placeholders.

<?php
defined( '_JEXEC' ) or die('Restricted access');
if (($this->error->getCode()) == '404') {
	echo file_get_contents('http://YOUR_DOMAIN/index.php?option=com_content&view=article&id=ARTICLE_ID');
}

This solution pulls in the content of the 'Page Not Found'. In fact it goes off and gets the whole page in its own request. Don't worry about the hideous looking URL - the users will never see it. Doing it this way will send the 404 error code back as well as the human readable error page your graphic designer crafted. FYI Joomla sets the 404 code in the header.

How Not to Set up a 404 with Joomla

Most online tutorials show a redirect method similar to:

<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
header("HTTP/1.0 404 Not Found");
header("Location: http://YOUR_DOMAIN/404");
exit;

The problem with this is the redirect will resolve with a 200 OK code. A 200 OK code tells the browser that the request was all ok. That is not good for Google! You need to tell Google that the page could not be found too.



Read

Once you have unpacked and installed a nice new shiny instance of Joomla what extensions take Joomla from being a fantastic CMS to being a super CMS?

I have tried many Joomla extensions, some are very good. The list of good extensions, I am happy to say, is longer than the list of bad ones. But, what extensions are so good, so brilliant, and so useful, they should be installed into each website you build with Joomla?

My Top 5 Must Have Joomla Extensions are:

#1 Akeeba Backup

Once you have made a website - losing it would not be fun. Having a recent backup means it is never lost for ever. All websites need to be backed up. Akeeba Backup is a great tool for this.

Akeeba backup is a fully automatic backup tool for Joomla. Akeeba backup makes a complete archive of your Joomla website. Akeeba backup can run as often as you need, both manually and automatically. Akeeba backup then can deposit the backup in to a separate storage drive - Dropbox is on the list.

Restoring a backup file is just as easy as running the Joomla installer using the Akeeba kick-start recovery script. Here is a bonus to note: you can use Akeeba backup to simply move a website from one server to the next - this option is so popular, it is built into the Akeeba Backup user interface.

I like Akeeba backup - it works. I have it making regular backups that are going to my choice of cloud storage. I have called on Akeeba backup on occasions without a problem.

You can find Akeeba backup via the Akeeba Backup website. Please note: I recommend the paid version. Some of the functions I have described may not be available to users of the free version.

#2 RSForm Pro

All websites need at least one form. The RSJoomla's RSForm Pro extension for Joomla enables making forms easy and even fun. RSForm Pro will help you setup forms and then mange those forms. RSForm Pro will help you with simple forms all the way through to complicated multi page forms. All types of forms are possible and made easy by RSJoomla's RSForm Pro extension for Joomla.

RSForm Pro has several plugins too. The plugins include: MailChimp integration; PayPal integration; and many more. If that is not enough, you can even map a form's field to another part of the database right from within the extension's user interface.

I like RSForm Pro. It's simple to use. Form submissions are easy to manage and exporting into other applications is not a problem.

Go get RSJoomla's RSForm pro today from their RSJoomla website.

#3 XMap

Once you have a website out there online, you want people to see it. You need it to be indexed by search engines. You need the pages to be found by search engines soon after you have added them. Most search engines accept an xml sitemap and will query it regularly to look for new content.

Vargas's XMap automatically produces your sitemaps. Once it is setup, you can leave it to it. Each time you add a page to your website, XMap will add the page to the sitemap for you. Once more, you can also have a copy of the sitemap in HTML format so that your human visitors can have a sitemap too.

I like Vargas's XMap because it's simple and lightweight. I like that other Joomla extension makers (particularly component extension makers), that are worth their salt, create XMap plugins so that content generated by their extension is mapped by XMap too.

You can find Vargas's XMap at the XMap website.

XMap Beautiful URL Tip

If you would like your sitemap to be found using www.yourdoman.com/sitemap.xml and not a long ugly string – paste this snippet into your HTACCESS file.

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/sitemap.xml
RewriteRule .* /index.php?option=com_xmap&view=xml

Note: you will need to adjust the query if you have more than one sitemap.

#4 GoogleAJAXLib

Everybody is using a CDN nowadays and why not? CDNs make your website load faster. The scripts get cached and are sent to the user from the closest data centre to them that the CDN is using.

ReSEO's GoogleAJAXLib for Joomla simply jumps in at the right point to swap the address of the Mootools JavaScript framework to the Google Ajax Lib CDN address. The GoogleAJAXLib extension will also do any of the frameworks that the Google Ajax Lib CDN will serve, this included jQuery. So if your template or other extensions are using a framework like jQuery, ReSEO's GoogleAJAXLib will swap the address for you.

As well as giving me access to the Google Ajax Lib CDN - I like ReSEO's GoogleAJAXLib extension because it has a simple lightweight implementation. The code works with the Joomla framework the way Joomla is supposed to be hooked into. In other words its implementation is not hacky at all.

You can find ReSEO's GoogleAJAXLib extension on their GoogleAJAXLib download page.

#5 Admin Tools

The Akeeba Admin Tools is the intelligent friend of Joomla. It makes Joomla run even faster, operate more securely, and looks out for Joomla to see if anything is amiss. Akeeba Admin Tools has a HTACCESS creation tool that will help you create a sweet .htaccess file suited to your needs. It has an active scanner that stops threats. The tool has a scanner that finds and identifies changes to files within your website's file system. The list of features is comprehensive.

I use Akeeba Admin Tools because they give me peace of mind. I also like that my websites are super-fast. Ok, Joomla is good at being fast and secure, I know, but we are talking super at and not just good at.

You can find Akeeba AdminTools via the Akeeba Admin Tools website.

Conclusion

After installing my top 5 Joomla extensions, you will start a new website that: backs itself up automatically and is easily recoverable. A website that can collect information from its visitors and send it to almost anywhere you like. Your new Joomla website will be easily indexable by search engines. The website will be super-fast and it will be super-secure.

What to look out for?

Look out for the age of this article! I have based this on the extensions I am using with Joomla 2.5 (The current production release). I have read on the Joomla JavaScript working group forum that there is a move to put the CDN functionality into the Joomla core.



Read

All the versions of Joomla I know have shipped with the GeSHi syntax highlighter. The GeSHi Syntax highlighter comes in the form of a plugin that is by default unpublished. Its power comes from the fact that it does all the syntax highlighting server side. Meaning caching can be taken full advantage of.

The GeSHi - Generic Syntax Highlighter is an award-winning piece of software released under the GNU GPL license and is packaged into a plugin by Joomla ready to be used by any author or publisher who needs to highlight the syntax of their examples.

When I found the Joomla GeSHi plugin, I discovered there was very little documentation on how to use the Joomla plugin. This may have been because it is quite easy to uses once you know how, however, I didn't know how at the time. I had to piece together very small snippets of information until the 'how to' for me came together.

Here is How to Use the Joomla GeSHi Plugin

The first step is to go to Joomla's plugin manager. Search for 'GeSHi' and publish the result. The Joomla GeSHi plugin will then be active ready for the Joomla's advanced event system (sometimes referred to as hooks in other CMS's terminology) to call it during 'onContentPrepare'.

Now when adding content simply use the HTML pre tag with the GeSHi xml:lang attribute. The value of the attribute needs to be the language that is to be syntax highlighted. For example:

<script type="text/javascrpt">
	/* Highlighted JavaScript stuff  */
</script>

will give you a syntax highlighted JavaScript snippet.

TinyMCE Gets in the Way of the Joomla GeSHi Plugin

Be warned TinyMCE is a bit of a pain when it comes to using the GeSHi plugin. The best solution is to just disable TinyMCE. What about the non-technical users? - you may ask. Well you can disable TinyMCE for your account only or the user group of authors who need syntax highlighting - for example you could set up a 'Technical Author' group. Another alternative I have found is to use the JCE editor. When the JCE editor is configured properly, it will play nicely with the GeSHi Joomla plugin.

What Languages Will the Joomla GeSHi Plugin Highlight?

Version 3 of Joomla will get GeSHi to highlight following:

  • CSS
  • Diff (Diff File Format)
  • HTML
  • ini (Configuration files)
  • JavaScript
  • MySQL
  • PHP
  • SQL
  • XML

They are All Triggered Respectively as Follows:

<pre xml:lang="CSS">
<pre xml:lang="Diff">
<pre xml:lang="HTML">
<pre xml:lang="INI">
<pre xml:lang="Javascript">
<pre xml:lang="MySQL">
<pre xml:lang="PHP">
<pre xml:lang="SQL">
<pre xml:lang="XML">

Conclusion

The Joomla GeSHi Plugin is a great tool for authors and publishers were syntax highlighting is in need. The Joomla GeSHi Plugin is not difficult to use as this article tries to show and help with. Out-of-the-box the Joomla GeSHi Plugin has a good selection of languages that technical bloggers and writers are likely to need. If the language you need is not included, please see below for: What if the language I need is not included? Otherwise I hope this article was helpful.

What if the Language I Need is Not Included?

Well you could just add it to the GeSHi folder within the plugin - that is how GeSHi itself works. However, as I am sure you know, this is hacking the Joomla core and is bad and unnecessary. The solution is to copy the Joomla GeSHi plugin folder to your local machine. Then add whichever languages you need that are available from the GeSHi project to the plugin's GeSHi folder. Then repackage it up with an amended install XML file, zip it, and install it back into Joomla. Do not forget to publish your extended version and you're away.

Here is one I prepared earlier that has all the languages GeSHi has available:

Note:

  • For performance reasons I recommend removing the languages you will not be using
  • It comes with no warranty

Tags: GeSHiJoomla

Read

Mailing List


Responsive Media

With the ResponsiveMedia plugin for Joomla it is easy to add 3rd party content from YouTube, Vimeo, and Instagram right in to any Joomla! article.

ResponsiveMedia