Beginner's Guide

A better alternative would be to use template overrides in each template. Copy the changed file to your
template folder to /httpdocs/templates/[template_name]/html/com_search/search/default.php and remove the
changes in the original file. The result on the webpage is the same but, behind the scenes, you have
overridden the original .../default.php file with your desired content layout - without changing core code -
well done!
This system was introduced in the year of 2007 with the release of Joomla 1.5 and still works very
well today.
Alternative layouts
In Joomla 2.5 the overrides have an enhancement called alternative layouts. I am sure you have already
seen the Alternative Layout field in the edit form of articles, modules and categories (Figure 5).
Figure 5: Alternative layout in an article
Why do we need alternative layouts? Imagine, you are an administrator or webmaster and a template
comes with three alternative layouts for an article. Sometimes it is a 'normal article', sometimes it should
look like a product, and sometimes like a book page. You only have to choose which layout you would
like to use. That sounds like a great feature and, of course, it is.
The technique is the same as with template overrides. You have to create a folder with the same
name as the component or module and a subfolder for the view. There are two differences:
1. Obviously the file name has to be something other than default.php as this one has already been
reserved for template overrides.
2. The alternative layout is, of course, not automatically selected.
Additionally to the alternative layout, menu item types can be added to the layout and the option
items of that article can be controlled by defining them in an xml file with the same name as the
alternative layout file (Figure 6).
Joomla! 2.5 - Beginner’s Guide
Monday, 30 January 2012! Page 196