<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Instance</id>
	<title>Joomla! Documentation - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Instance"/>
	<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/Special:Contributions/Instance"/>
	<updated>2026-06-11T17:19:15Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8983</id>
		<title>Understanding Output Overrides</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8983"/>
		<updated>2008-07-05T14:30:00Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Customise the Component Output */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Understanding Output Overrides in &amp;quot;Joomla!&amp;quot; 1.5 =&lt;br /&gt;
Written by Andrew Eddie&lt;br /&gt;
&lt;br /&gt;
This was Developer Blog post by Andrew, initially copied to the wiki with minor edits by Alan Langford. This is still a work in progress.&lt;br /&gt;
== Introduction ==&lt;br /&gt;
There are many competing requirements for web designers ranging from accessibility to legislative to personal preferences.  Rather than trying to over-parameterise views, or trying to aim for some sort of line of best fit, or worse, sticking its head in the sand, &amp;quot;Joomla!&amp;quot; has added the potential for the designer to take over control of virtually all of the output that is generated.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; has been criticized by some for not giving due attention to accessibility or being archaic in their approach to web standards. However with 1.5, the responsibility, but more importantly the power is back in the designer&#039;s hands.&lt;br /&gt;
&lt;br /&gt;
In addition, except for files that are provided in the &amp;quot;Joomla!&amp;quot; distribution itself, these methods for customisation eliminate the need for designers and developers to &amp;quot;hack&amp;quot; core files that could change when the site is updated to a new version.  Because they are contained within the template, they can be deployed to the Web site without having to worry about changes being accidentally overwritten when your System Administrator upgrades the site.&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to introduce the how fours areas of the output of &amp;quot;Joomla!&amp;quot; are able to be customised by the template designer.&lt;br /&gt;
&lt;br /&gt;
Not interested in all the theory?  Jump straight to the cheat sheet.&lt;br /&gt;
== MVC 101 ==&lt;br /&gt;
MVC can be a scary acronym.  It stands for Model-View-Controller and the concepts behind MVC are responsible for the extra flexibility that is now afforded to the designer.  While parts of the theory can be rather involved and complicated, the only part that the designer need worry about is the V for View.  This is the part that is concerned with output.&lt;br /&gt;
&lt;br /&gt;
Different extensions display output in different ways.&lt;br /&gt;
&lt;br /&gt;
Components, as you would already know, are fairly complex and have the ability to display different information in different ways.  For example, the Articles Component (com_content) is able to display a single article, or articles in a category, or categories in a section.  Each of the ways of representing the different types of data (an article, or a category, or a section) is called a &amp;quot;view&amp;quot; (this comes from our MVC terminology).  Most components will have many views.  However, the view doesn&#039;t actually display the output.  This is left up to what we call a &amp;quot;layout&amp;quot; and it is possible for a view to have a variety of layouts.&lt;br /&gt;
&lt;br /&gt;
The main thing to remember here is that components can have multiple views, and each view can have one or more layouts.  Each view assembles a fixed set of information, but each layout can display that information in different ways.  For example, the Category view in the Articles component assembles a number of articles.  These articles could be displayed in a list or in a table (and probably other ways as well).  So this view may have a &amp;quot;list&amp;quot; layout and a &amp;quot;table&amp;quot; layout to choose from.&lt;br /&gt;
&lt;br /&gt;
Modules, on the other hand, are very simple.  They generally display one thing one way.  Modules don&#039;t really have views but they do support a layout.  Some developers might even support a choice of layout through module parameters.&lt;br /&gt;
=== Template versus Layout ===&lt;br /&gt;
&lt;br /&gt;
It is very important to distinguish between the role of template and the role of layouts.  The template sets up a structural framework for the page of the Web site.  Within this framework are positions for modules and a component to display.  What actually gets displayed is governed by the module layout, or the combination of view and layout in the case of the component.&lt;br /&gt;
&lt;br /&gt;
The following image shows the structural layout of a typical &amp;quot;Joomla!&amp;quot; template (rhuk_milkyway, the default for 1.5).  The module positions are displayed by adding tp=1 to the URL (eg, index.php?tp=1).  You can clearly see where the module output is contained within the overall template, as well as the main component output starting in the lower-centre region.  However, what is actually output in those regions, is controlled by the layouts.&lt;br /&gt;
&lt;br /&gt;
[[Image:FrontpageTemplatePositions.png|Typical Joomla! screenshot with template positions shown.]]&lt;br /&gt;
&lt;br /&gt;
=== Ancillary Customisation ===&lt;br /&gt;
&lt;br /&gt;
While not strictly related to the MVC, there are two other important areas to consider when looking at customising the output of &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In addition to layouts, modules have what we call &amp;quot;chrome&amp;quot;.  Chrome is the style with which a module is to display.  Most developers, designers and probably some end-users will be familiar with the different built-in styles for modules (raw, xhtml, etc).  It is also possible to define your own chrome styles for modules depending on the designer result.  For example, you could design a chrome to display all the modules in a particular position in a fancy Javascript collapsing blind arrangement.&lt;br /&gt;
&lt;br /&gt;
In the screenshot above, you can just make out the names of some of the built-in module chrome used (rounded, none and xhtml).&lt;br /&gt;
&lt;br /&gt;
The second area has to do with controlling the pagination controls when viewing lists of data.  We will look at that in more detail later.&lt;br /&gt;
== Component Output Types and Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
To understand layout overrides we must first understand the file structure of a component.  While there are many parts to a component, all fulfilling different roles and responsibilities, we want to look just in the /views/ directory.  Here is the partial structure for two of the com_content views:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/components&lt;br /&gt;
  /com_content&lt;br /&gt;
	/views&lt;br /&gt;
	  /articles&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  default.php (this is a layout)&lt;br /&gt;
		  form.php	(this is a layout)&lt;br /&gt;
		view.html.php (this is the view that outputs the HTML)&lt;br /&gt;
		view.pdf.php  (this is the view that outputs the PDF)&lt;br /&gt;
	  /category&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  blog.php	   (layout)&lt;br /&gt;
		  blog_items.php (a sub-layout&lt;br /&gt;
		  default.php	(layout)&lt;br /&gt;
		view.html.php	(HTML view)&lt;br /&gt;
		view.feed.php	(RSS feed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
So what you see here is that under the /views/ directory, each view is placed in a directory of its own.  The content component actually has three other views not shown: archive, frontpage and section.&lt;br /&gt;
=== Output Types ===&lt;br /&gt;
Under the /articles/ directory we have a number of files.  There is almost always a file called view.html.php.  This is what we call the view file, but there can be more than one depending on the type of output to produce.  It has a specific naming convention, view.output_type.php, where the output type can be html, feed, pdf, raw or error (for more information see JDocument in the API reference and look in the directory /libraries/joomla/document/).  What this means is when we want html output for this particular view, the view.html.php file is used.  When we want the RSS output, the view.feed.php file is used.&lt;br /&gt;
&lt;br /&gt;
The affect of these different output types is most apparent when the Global Configuration setting for Search Engine Friendly URLs is set to Yes, Use Apache mod_rewrite is set to Yes, and Add suffix to URLs is also set to Yes.  When this is done, the site URLs will look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://domain/sports.html&lt;br /&gt;
http://domain/sports.feed&lt;br /&gt;
http://domain/sports/rowing.html&lt;br /&gt;
http://domain/sports/rowing.pdf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The exact URL will vary depending on how you set up your site but the point here is to show that sports.html will use the category view&#039;s view.html.php file to, and that sports.feed will display the RSS feed for the category using view.feed.php.  It should be noted that you cannot currently customise feed or PDF output types.  However, you can customise the html output type and this is where layouts come into play.&lt;br /&gt;
&lt;br /&gt;
=== Layouts ===&lt;br /&gt;
Under the view directory there is a /tmpl/ directory in which the layout files reside.  Each PHP file in this directory represents a layout.  For example, article/tmpl/default.php is the default layout for an article whereas article/tmpl/form.php is the edit form for an article; category/tmpl/default.php is the default layout for a category whereas category/tmpl/blog.php displays the list of article differently.&lt;br /&gt;
&lt;br /&gt;
The relationship between component views and layout is most plainly seen when adding a new menu item.  The next screenshot represents the typical display of the New Menu Item page.  Having clicked on Articles (which represents com_content), the tree expands to show the list of views and each layout within the view.&lt;br /&gt;
&lt;br /&gt;
[[Image:Menu_item_type_articles.png|Screenshot of creating a new menu item fro an article.]]&lt;br /&gt;
&lt;br /&gt;
You will notice that while there are extra files in some of the /tmpl/ directories (like pagebreak.php in the article view), they are missing from the list.  This is due to instructions in the XML file for the layout (for example, pagebreak.xml) to hide the layout (or even the view) from the menu item list.  However, this is another broad topic which will be covered in another tutorial.&lt;br /&gt;
&lt;br /&gt;
Armed with all that knowledge of how all the parts relate to each other, we are now ready to actually create our layout overrides.&lt;br /&gt;
&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
Layout overrides only work within the active template and are located under the /html/ directory in the template.  For example, the overrides for rhuk_milkyway are located under /templates/rhuk_milkyway/html/, for the JA Purity template under /templates/ja_purity/html/ and for Beez under /templates/beez/html/.&lt;br /&gt;
&lt;br /&gt;
It is important to understand that if you create overrides in one template, they will not be available in other templates.  For example, rhuk_milkyway has no component layout overrides at all.  When you use this template you are seeing the raw output from all components.  When you use the Beez template, almost every piece of component output is being controlled by the layout overrides in the template.  JA Purity is in between having overrides for some components and only some views of those components.&lt;br /&gt;
&lt;br /&gt;
The layout overrides must be placed in particular way.  Using Beez as an example you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /com_content	(this directory matches the component directory name)&lt;br /&gt;
		/articles	 (this directory matches the view directory name)&lt;br /&gt;
		  default.php (this file matches the layout file name)&lt;br /&gt;
		  form.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure for component overrides is quite simple: /html/com_component_name/view_name/layout_file_name.php.  Let&#039;s look at a few examples.&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any components.  If we want to override the default layout for an article, first we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the appropriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
If we wanted to override the blog layout in the category view, we would copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog.php&lt;br /&gt;
&lt;br /&gt;
Once the files are copied, you are free to customise these files as much or as little as required or desired.  You do not have to honour parameter settings if you don&#039;t want to.&lt;br /&gt;
=== Overriding Sub-Layouts ===&lt;br /&gt;
&lt;br /&gt;
In some views you will see that some of the layouts have a group of files that start with the same name.  The category view has an example of this.  The blog layout actually has three parts: the main layout file blog.php and two sub-layout files, blog_item.php and blog_links.php.  You can see where these sub-layouts are loaded in the blog.php file using the loadTemplate method, for example:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;item&#039;);&lt;br /&gt;
// or&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;links&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
When loading sub-layouts, the view already knows what layout you are in, so you don&#039;t have to provide the prefix (that is, you load just &#039;item&#039;, not &#039;blog_item&#039;).&lt;br /&gt;
&lt;br /&gt;
What is important to note here is that it is possible to override just a sub-layout without copying the whole set of files.  For example, if you were happy with the &amp;quot;Joomla!&amp;quot; default output for the blog layout, but just wanted to customise the item sub-layout, you could just copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog_item.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog_item.php&lt;br /&gt;
&lt;br /&gt;
When &amp;quot;Joomla!&amp;quot; is parsing the view, it will automatically know to load blog.php from com_content natively and blog_item.php from your template overrides.&lt;br /&gt;
== Module Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
Modules, like components, are set up in a particular directory structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/modules&lt;br /&gt;
  /mod_latest_news&lt;br /&gt;
	/tmpl&lt;br /&gt;
	  default.php	   (the layout)&lt;br /&gt;
	helper.php		  (a helper file containing data logic)&lt;br /&gt;
	mod_latest_news.php (the main module file)&lt;br /&gt;
	mod_latest_news.xml (the installation XML file)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Similar to components, under the main module directory (in the example, mod_latest_news) there is a /tmpl/ directory.  There is usually only one layout file but depending on who wrote the module, and how it is written, there could be more.&lt;br /&gt;
&lt;br /&gt;
As for components, the layout override for a module must be placed in particular way.  Using Beez as an example again, you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /mod_latest_news.php (this directory matches the module directory name)&lt;br /&gt;
		default.php		(this file matches the layout file name)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The structure for module overrides is again quite simple: /html/mod_module_name/layout_file_name.php.&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any modules.  If we want to override the default layout for Latest News module, we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the approriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
You need to take a little care with overriding module layout because there are a number of different ways that modules can or have been designed so you need to treat each one individually.&lt;br /&gt;
== Module Chrome ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.0 had a number of fixed styles that could display a list of modules in a particular position.  These where represented by numbers:&lt;br /&gt;
&lt;br /&gt;
* 0 (the default) displayed modules in a vertical table&lt;br /&gt;
* 1 displayed them in a horizontal table&lt;br /&gt;
* -1 displayed the raw module output&lt;br /&gt;
* -2 displayed the modules in a XHTML compatible format with the title in a H3 tag.&lt;br /&gt;
* -3 displayed modules in a set of nested DIVs that allowed for rounded-corner techniques&lt;br /&gt;
&lt;br /&gt;
It was a great system except for two things:&lt;br /&gt;
&lt;br /&gt;
# Nobody could remember which number was which, and&lt;br /&gt;
# You couldn&#039;t expand on the styles.&lt;br /&gt;
&lt;br /&gt;
Well, in 1.5, the numbers are still recognised, but more commonly the style is represented as a word.  As well as that, the syntax for displaying a module position was changed.  For example, this snippet displays each module in the left position in the xhtml style:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;jdoc:include type=&amp;quot;modules&amp;quot; name=&amp;quot;left&amp;quot; style=&amp;quot;xhtml&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The built-in styles that are now available are:&lt;br /&gt;
&lt;br /&gt;
* table (was 0 and is the default)&lt;br /&gt;
* horz (was 1)&lt;br /&gt;
* none (was -1)&lt;br /&gt;
* xhtml (was -2)&lt;br /&gt;
* rounded (was -3)&lt;br /&gt;
* outline (new - used to preview module positions - see screenshot above)&lt;br /&gt;
&lt;br /&gt;
In the source code, these styles are actually referred to ask &amp;quot;chrome&amp;quot;.  The default chrome can actually be found in the system template provided in the default &amp;quot;Joomla!&amp;quot; install:&lt;br /&gt;
&lt;br /&gt;
/templates/system/html/modules.php&lt;br /&gt;
&lt;br /&gt;
This file is maintained by the project so you should never modify it directly otherwise there is a risk that you will loose your changes if and when you upgrade your &amp;quot;Joomla!&amp;quot; installation.&lt;br /&gt;
&lt;br /&gt;
To create your own chrome, or module styles, all you need to do is create or edit modules.php under the templates /html/ directory (this is the same directory we have been talking about for component and module layout overrides).&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template actually does provide some extra chrome as an example (it provides and new example style called &amp;quot;slider&amp;quot;).  This can be found in the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
To create your own chrome is really easy.  Let&#039;s look at ficticious example that displays the module in a Definition List (a set of DL&#039;s, DT&#039;s and DD&#039;s).&lt;br /&gt;
&lt;br /&gt;
Just add the following function to the /html/modules.php file in your default template directory (create it if it does not exist):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * Module chrome that wraps the module in a definition list&lt;br /&gt;
 */&lt;br /&gt;
function modChrome_dlist($module, &amp;amp;$params, &amp;amp;$attribs)&lt;br /&gt;
{ ?&amp;gt;&lt;br /&gt;
	&amp;lt;dl class=&amp;quot;&amp;lt;?php echo $params-&amp;gt;get(&#039;moduleclass_sfx&#039;); ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;?php if ($module-&amp;gt;showtitle != 0) : ?&amp;gt;&lt;br /&gt;
		&amp;lt;dt&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;title; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dt&amp;gt;&lt;br /&gt;
	&amp;lt;?php endif; ?&amp;gt;&lt;br /&gt;
		&amp;lt;dd&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;content; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dd&amp;gt;&lt;br /&gt;
	&amp;lt;/dl&amp;gt;&lt;br /&gt;
	&amp;lt;?php&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We will be calling the style &amp;quot;dlist&amp;quot;, so the name of the function needs to be modChrome_dlist.&lt;br /&gt;
&lt;br /&gt;
The function must take the three arguments as shown for the module object, the module parameters, and lastly the $attribs is an array of all the attributes in the jdoc XML tag.&lt;br /&gt;
&lt;br /&gt;
There are three main properties in the module object to be concerned with:&lt;br /&gt;
&lt;br /&gt;
* showtitle tells you whether to show the title of the module of not&lt;br /&gt;
* title is the title of the module&lt;br /&gt;
* content is the output of the module (from its layout)&lt;br /&gt;
&lt;br /&gt;
This is a very simple case and you can of course design more complex styles, possibly using custom atrributes in the XML tag.&lt;br /&gt;
== Pagination Links Overrides ==&lt;br /&gt;
&lt;br /&gt;
The final override we will look at is the pagination override.  This override can control the display of items-per-page and the pagination links that are used with lists of information, as shown in the following screenshot.&lt;br /&gt;
&lt;br /&gt;
[[Image:Article_list_pagination.png|Typical Joomla! page showing a paginated list.]]&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template provides a well commented example for this override.  The file is found here:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
When the pagination list is required, &amp;quot;Joomla!&amp;quot; will look for this file in the default templates.  If it is found it will be loaded and the display functions it contains will be used.&lt;br /&gt;
&lt;br /&gt;
There are four functions that can be used:&lt;br /&gt;
&lt;br /&gt;
pagination_list_footer&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the select list for the number of items to display per page.&lt;br /&gt;
&lt;br /&gt;
pagination_list_render&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the list of page number links as well at the Start, End, Previous and Next links.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the links to other page numbers other than the &amp;quot;current&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the current page number, usually not hyperlinked.&lt;br /&gt;
&lt;br /&gt;
== Cheat Sheet ==&lt;br /&gt;
&lt;br /&gt;
Using the rhuk_milkyway template as an example, here is a brief summary of the priniciples we&#039;ve looked at.&lt;br /&gt;
=== Customise the Component Output ===&lt;br /&gt;
&lt;br /&gt;
To override a component layout (for example the default layout in the article view), copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about [[#Component Output Types and Layout Overrides|component output]].&lt;br /&gt;
&lt;br /&gt;
=== Customise the Module Output ===&lt;br /&gt;
&lt;br /&gt;
To override a module layout (for example the Latest News module using the rhuk_milkyway template), copy:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about [[#Module Layout Overrides|module output]].&lt;br /&gt;
&lt;br /&gt;
=== Add New Module Styles ===&lt;br /&gt;
&lt;br /&gt;
To add new module styles (chrome), add them to the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
Read more about [[#Module Chrome|module chrome]].&lt;br /&gt;
&lt;br /&gt;
=== Customise the Pagination Links ===&lt;br /&gt;
&lt;br /&gt;
To customise the way the items-per-page selector and pagination links display, edit the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
Read more about [[#Pagination Links Overrides|pagination]].&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.5, through the use of an MVC paradigm has greatly improved the flexibility that is afforded to Web site designers.  By way of a few simple principles, like copying certain files to certain places in your template, the designer is able to override almost all of the output generated by &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If you have any questions relating to output overrides please let us know so that we can improve this tutorial.&lt;br /&gt;
&lt;br /&gt;
If you have translated this article into another language, please let us know.&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8982</id>
		<title>Understanding Output Overrides</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8982"/>
		<updated>2008-07-05T14:28:47Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Customise the Component Output */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Understanding Output Overrides in &amp;quot;Joomla!&amp;quot; 1.5 =&lt;br /&gt;
Written by Andrew Eddie&lt;br /&gt;
&lt;br /&gt;
This was Developer Blog post by Andrew, initially copied to the wiki with minor edits by Alan Langford. This is still a work in progress.&lt;br /&gt;
== Introduction ==&lt;br /&gt;
There are many competing requirements for web designers ranging from accessibility to legislative to personal preferences.  Rather than trying to over-parameterise views, or trying to aim for some sort of line of best fit, or worse, sticking its head in the sand, &amp;quot;Joomla!&amp;quot; has added the potential for the designer to take over control of virtually all of the output that is generated.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; has been criticized by some for not giving due attention to accessibility or being archaic in their approach to web standards. However with 1.5, the responsibility, but more importantly the power is back in the designer&#039;s hands.&lt;br /&gt;
&lt;br /&gt;
In addition, except for files that are provided in the &amp;quot;Joomla!&amp;quot; distribution itself, these methods for customisation eliminate the need for designers and developers to &amp;quot;hack&amp;quot; core files that could change when the site is updated to a new version.  Because they are contained within the template, they can be deployed to the Web site without having to worry about changes being accidentally overwritten when your System Administrator upgrades the site.&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to introduce the how fours areas of the output of &amp;quot;Joomla!&amp;quot; are able to be customised by the template designer.&lt;br /&gt;
&lt;br /&gt;
Not interested in all the theory?  Jump straight to the cheat sheet.&lt;br /&gt;
== MVC 101 ==&lt;br /&gt;
MVC can be a scary acronym.  It stands for Model-View-Controller and the concepts behind MVC are responsible for the extra flexibility that is now afforded to the designer.  While parts of the theory can be rather involved and complicated, the only part that the designer need worry about is the V for View.  This is the part that is concerned with output.&lt;br /&gt;
&lt;br /&gt;
Different extensions display output in different ways.&lt;br /&gt;
&lt;br /&gt;
Components, as you would already know, are fairly complex and have the ability to display different information in different ways.  For example, the Articles Component (com_content) is able to display a single article, or articles in a category, or categories in a section.  Each of the ways of representing the different types of data (an article, or a category, or a section) is called a &amp;quot;view&amp;quot; (this comes from our MVC terminology).  Most components will have many views.  However, the view doesn&#039;t actually display the output.  This is left up to what we call a &amp;quot;layout&amp;quot; and it is possible for a view to have a variety of layouts.&lt;br /&gt;
&lt;br /&gt;
The main thing to remember here is that components can have multiple views, and each view can have one or more layouts.  Each view assembles a fixed set of information, but each layout can display that information in different ways.  For example, the Category view in the Articles component assembles a number of articles.  These articles could be displayed in a list or in a table (and probably other ways as well).  So this view may have a &amp;quot;list&amp;quot; layout and a &amp;quot;table&amp;quot; layout to choose from.&lt;br /&gt;
&lt;br /&gt;
Modules, on the other hand, are very simple.  They generally display one thing one way.  Modules don&#039;t really have views but they do support a layout.  Some developers might even support a choice of layout through module parameters.&lt;br /&gt;
=== Template versus Layout ===&lt;br /&gt;
&lt;br /&gt;
It is very important to distinguish between the role of template and the role of layouts.  The template sets up a structural framework for the page of the Web site.  Within this framework are positions for modules and a component to display.  What actually gets displayed is governed by the module layout, or the combination of view and layout in the case of the component.&lt;br /&gt;
&lt;br /&gt;
The following image shows the structural layout of a typical &amp;quot;Joomla!&amp;quot; template (rhuk_milkyway, the default for 1.5).  The module positions are displayed by adding tp=1 to the URL (eg, index.php?tp=1).  You can clearly see where the module output is contained within the overall template, as well as the main component output starting in the lower-centre region.  However, what is actually output in those regions, is controlled by the layouts.&lt;br /&gt;
&lt;br /&gt;
[[Image:FrontpageTemplatePositions.png|Typical Joomla! screenshot with template positions shown.]]&lt;br /&gt;
&lt;br /&gt;
=== Ancillary Customisation ===&lt;br /&gt;
&lt;br /&gt;
While not strictly related to the MVC, there are two other important areas to consider when looking at customising the output of &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In addition to layouts, modules have what we call &amp;quot;chrome&amp;quot;.  Chrome is the style with which a module is to display.  Most developers, designers and probably some end-users will be familiar with the different built-in styles for modules (raw, xhtml, etc).  It is also possible to define your own chrome styles for modules depending on the designer result.  For example, you could design a chrome to display all the modules in a particular position in a fancy Javascript collapsing blind arrangement.&lt;br /&gt;
&lt;br /&gt;
In the screenshot above, you can just make out the names of some of the built-in module chrome used (rounded, none and xhtml).&lt;br /&gt;
&lt;br /&gt;
The second area has to do with controlling the pagination controls when viewing lists of data.  We will look at that in more detail later.&lt;br /&gt;
== Component Output Types and Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
To understand layout overrides we must first understand the file structure of a component.  While there are many parts to a component, all fulfilling different roles and responsibilities, we want to look just in the /views/ directory.  Here is the partial structure for two of the com_content views:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/components&lt;br /&gt;
  /com_content&lt;br /&gt;
	/views&lt;br /&gt;
	  /articles&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  default.php (this is a layout)&lt;br /&gt;
		  form.php	(this is a layout)&lt;br /&gt;
		view.html.php (this is the view that outputs the HTML)&lt;br /&gt;
		view.pdf.php  (this is the view that outputs the PDF)&lt;br /&gt;
	  /category&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  blog.php	   (layout)&lt;br /&gt;
		  blog_items.php (a sub-layout&lt;br /&gt;
		  default.php	(layout)&lt;br /&gt;
		view.html.php	(HTML view)&lt;br /&gt;
		view.feed.php	(RSS feed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
So what you see here is that under the /views/ directory, each view is placed in a directory of its own.  The content component actually has three other views not shown: archive, frontpage and section.&lt;br /&gt;
=== Output Types ===&lt;br /&gt;
Under the /articles/ directory we have a number of files.  There is almost always a file called view.html.php.  This is what we call the view file, but there can be more than one depending on the type of output to produce.  It has a specific naming convention, view.output_type.php, where the output type can be html, feed, pdf, raw or error (for more information see JDocument in the API reference and look in the directory /libraries/joomla/document/).  What this means is when we want html output for this particular view, the view.html.php file is used.  When we want the RSS output, the view.feed.php file is used.&lt;br /&gt;
&lt;br /&gt;
The affect of these different output types is most apparent when the Global Configuration setting for Search Engine Friendly URLs is set to Yes, Use Apache mod_rewrite is set to Yes, and Add suffix to URLs is also set to Yes.  When this is done, the site URLs will look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://domain/sports.html&lt;br /&gt;
http://domain/sports.feed&lt;br /&gt;
http://domain/sports/rowing.html&lt;br /&gt;
http://domain/sports/rowing.pdf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The exact URL will vary depending on how you set up your site but the point here is to show that sports.html will use the category view&#039;s view.html.php file to, and that sports.feed will display the RSS feed for the category using view.feed.php.  It should be noted that you cannot currently customise feed or PDF output types.  However, you can customise the html output type and this is where layouts come into play.&lt;br /&gt;
&lt;br /&gt;
=== Layouts ===&lt;br /&gt;
Under the view directory there is a /tmpl/ directory in which the layout files reside.  Each PHP file in this directory represents a layout.  For example, article/tmpl/default.php is the default layout for an article whereas article/tmpl/form.php is the edit form for an article; category/tmpl/default.php is the default layout for a category whereas category/tmpl/blog.php displays the list of article differently.&lt;br /&gt;
&lt;br /&gt;
The relationship between component views and layout is most plainly seen when adding a new menu item.  The next screenshot represents the typical display of the New Menu Item page.  Having clicked on Articles (which represents com_content), the tree expands to show the list of views and each layout within the view.&lt;br /&gt;
&lt;br /&gt;
[[Image:Menu_item_type_articles.png|Screenshot of creating a new menu item fro an article.]]&lt;br /&gt;
&lt;br /&gt;
You will notice that while there are extra files in some of the /tmpl/ directories (like pagebreak.php in the article view), they are missing from the list.  This is due to instructions in the XML file for the layout (for example, pagebreak.xml) to hide the layout (or even the view) from the menu item list.  However, this is another broad topic which will be covered in another tutorial.&lt;br /&gt;
&lt;br /&gt;
Armed with all that knowledge of how all the parts relate to each other, we are now ready to actually create our layout overrides.&lt;br /&gt;
&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
Layout overrides only work within the active template and are located under the /html/ directory in the template.  For example, the overrides for rhuk_milkyway are located under /templates/rhuk_milkyway/html/, for the JA Purity template under /templates/ja_purity/html/ and for Beez under /templates/beez/html/.&lt;br /&gt;
&lt;br /&gt;
It is important to understand that if you create overrides in one template, they will not be available in other templates.  For example, rhuk_milkyway has no component layout overrides at all.  When you use this template you are seeing the raw output from all components.  When you use the Beez template, almost every piece of component output is being controlled by the layout overrides in the template.  JA Purity is in between having overrides for some components and only some views of those components.&lt;br /&gt;
&lt;br /&gt;
The layout overrides must be placed in particular way.  Using Beez as an example you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /com_content	(this directory matches the component directory name)&lt;br /&gt;
		/articles	 (this directory matches the view directory name)&lt;br /&gt;
		  default.php (this file matches the layout file name)&lt;br /&gt;
		  form.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure for component overrides is quite simple: /html/com_component_name/view_name/layout_file_name.php.  Let&#039;s look at a few examples.&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any components.  If we want to override the default layout for an article, first we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the appropriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
If we wanted to override the blog layout in the category view, we would copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog.php&lt;br /&gt;
&lt;br /&gt;
Once the files are copied, you are free to customise these files as much or as little as required or desired.  You do not have to honour parameter settings if you don&#039;t want to.&lt;br /&gt;
=== Overriding Sub-Layouts ===&lt;br /&gt;
&lt;br /&gt;
In some views you will see that some of the layouts have a group of files that start with the same name.  The category view has an example of this.  The blog layout actually has three parts: the main layout file blog.php and two sub-layout files, blog_item.php and blog_links.php.  You can see where these sub-layouts are loaded in the blog.php file using the loadTemplate method, for example:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;item&#039;);&lt;br /&gt;
// or&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;links&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
When loading sub-layouts, the view already knows what layout you are in, so you don&#039;t have to provide the prefix (that is, you load just &#039;item&#039;, not &#039;blog_item&#039;).&lt;br /&gt;
&lt;br /&gt;
What is important to note here is that it is possible to override just a sub-layout without copying the whole set of files.  For example, if you were happy with the &amp;quot;Joomla!&amp;quot; default output for the blog layout, but just wanted to customise the item sub-layout, you could just copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog_item.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog_item.php&lt;br /&gt;
&lt;br /&gt;
When &amp;quot;Joomla!&amp;quot; is parsing the view, it will automatically know to load blog.php from com_content natively and blog_item.php from your template overrides.&lt;br /&gt;
== Module Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
Modules, like components, are set up in a particular directory structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/modules&lt;br /&gt;
  /mod_latest_news&lt;br /&gt;
	/tmpl&lt;br /&gt;
	  default.php	   (the layout)&lt;br /&gt;
	helper.php		  (a helper file containing data logic)&lt;br /&gt;
	mod_latest_news.php (the main module file)&lt;br /&gt;
	mod_latest_news.xml (the installation XML file)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Similar to components, under the main module directory (in the example, mod_latest_news) there is a /tmpl/ directory.  There is usually only one layout file but depending on who wrote the module, and how it is written, there could be more.&lt;br /&gt;
&lt;br /&gt;
As for components, the layout override for a module must be placed in particular way.  Using Beez as an example again, you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /mod_latest_news.php (this directory matches the module directory name)&lt;br /&gt;
		default.php		(this file matches the layout file name)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The structure for module overrides is again quite simple: /html/mod_module_name/layout_file_name.php.&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any modules.  If we want to override the default layout for Latest News module, we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the approriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
You need to take a little care with overriding module layout because there are a number of different ways that modules can or have been designed so you need to treat each one individually.&lt;br /&gt;
== Module Chrome ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.0 had a number of fixed styles that could display a list of modules in a particular position.  These where represented by numbers:&lt;br /&gt;
&lt;br /&gt;
* 0 (the default) displayed modules in a vertical table&lt;br /&gt;
* 1 displayed them in a horizontal table&lt;br /&gt;
* -1 displayed the raw module output&lt;br /&gt;
* -2 displayed the modules in a XHTML compatible format with the title in a H3 tag.&lt;br /&gt;
* -3 displayed modules in a set of nested DIVs that allowed for rounded-corner techniques&lt;br /&gt;
&lt;br /&gt;
It was a great system except for two things:&lt;br /&gt;
&lt;br /&gt;
# Nobody could remember which number was which, and&lt;br /&gt;
# You couldn&#039;t expand on the styles.&lt;br /&gt;
&lt;br /&gt;
Well, in 1.5, the numbers are still recognised, but more commonly the style is represented as a word.  As well as that, the syntax for displaying a module position was changed.  For example, this snippet displays each module in the left position in the xhtml style:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;jdoc:include type=&amp;quot;modules&amp;quot; name=&amp;quot;left&amp;quot; style=&amp;quot;xhtml&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The built-in styles that are now available are:&lt;br /&gt;
&lt;br /&gt;
* table (was 0 and is the default)&lt;br /&gt;
* horz (was 1)&lt;br /&gt;
* none (was -1)&lt;br /&gt;
* xhtml (was -2)&lt;br /&gt;
* rounded (was -3)&lt;br /&gt;
* outline (new - used to preview module positions - see screenshot above)&lt;br /&gt;
&lt;br /&gt;
In the source code, these styles are actually referred to ask &amp;quot;chrome&amp;quot;.  The default chrome can actually be found in the system template provided in the default &amp;quot;Joomla!&amp;quot; install:&lt;br /&gt;
&lt;br /&gt;
/templates/system/html/modules.php&lt;br /&gt;
&lt;br /&gt;
This file is maintained by the project so you should never modify it directly otherwise there is a risk that you will loose your changes if and when you upgrade your &amp;quot;Joomla!&amp;quot; installation.&lt;br /&gt;
&lt;br /&gt;
To create your own chrome, or module styles, all you need to do is create or edit modules.php under the templates /html/ directory (this is the same directory we have been talking about for component and module layout overrides).&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template actually does provide some extra chrome as an example (it provides and new example style called &amp;quot;slider&amp;quot;).  This can be found in the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
To create your own chrome is really easy.  Let&#039;s look at ficticious example that displays the module in a Definition List (a set of DL&#039;s, DT&#039;s and DD&#039;s).&lt;br /&gt;
&lt;br /&gt;
Just add the following function to the /html/modules.php file in your default template directory (create it if it does not exist):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * Module chrome that wraps the module in a definition list&lt;br /&gt;
 */&lt;br /&gt;
function modChrome_dlist($module, &amp;amp;$params, &amp;amp;$attribs)&lt;br /&gt;
{ ?&amp;gt;&lt;br /&gt;
	&amp;lt;dl class=&amp;quot;&amp;lt;?php echo $params-&amp;gt;get(&#039;moduleclass_sfx&#039;); ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;?php if ($module-&amp;gt;showtitle != 0) : ?&amp;gt;&lt;br /&gt;
		&amp;lt;dt&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;title; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dt&amp;gt;&lt;br /&gt;
	&amp;lt;?php endif; ?&amp;gt;&lt;br /&gt;
		&amp;lt;dd&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;content; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dd&amp;gt;&lt;br /&gt;
	&amp;lt;/dl&amp;gt;&lt;br /&gt;
	&amp;lt;?php&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We will be calling the style &amp;quot;dlist&amp;quot;, so the name of the function needs to be modChrome_dlist.&lt;br /&gt;
&lt;br /&gt;
The function must take the three arguments as shown for the module object, the module parameters, and lastly the $attribs is an array of all the attributes in the jdoc XML tag.&lt;br /&gt;
&lt;br /&gt;
There are three main properties in the module object to be concerned with:&lt;br /&gt;
&lt;br /&gt;
* showtitle tells you whether to show the title of the module of not&lt;br /&gt;
* title is the title of the module&lt;br /&gt;
* content is the output of the module (from its layout)&lt;br /&gt;
&lt;br /&gt;
This is a very simple case and you can of course design more complex styles, possibly using custom atrributes in the XML tag.&lt;br /&gt;
== Pagination Links Overrides ==&lt;br /&gt;
&lt;br /&gt;
The final override we will look at is the pagination override.  This override can control the display of items-per-page and the pagination links that are used with lists of information, as shown in the following screenshot.&lt;br /&gt;
&lt;br /&gt;
[[Image:Article_list_pagination.png|Typical Joomla! page showing a paginated list.]]&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template provides a well commented example for this override.  The file is found here:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
When the pagination list is required, &amp;quot;Joomla!&amp;quot; will look for this file in the default templates.  If it is found it will be loaded and the display functions it contains will be used.&lt;br /&gt;
&lt;br /&gt;
There are four functions that can be used:&lt;br /&gt;
&lt;br /&gt;
pagination_list_footer&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the select list for the number of items to display per page.&lt;br /&gt;
&lt;br /&gt;
pagination_list_render&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the list of page number links as well at the Start, End, Previous and Next links.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the links to other page numbers other than the &amp;quot;current&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the current page number, usually not hyperlinked.&lt;br /&gt;
&lt;br /&gt;
== Cheat Sheet ==&lt;br /&gt;
&lt;br /&gt;
Using the rhuk_milkyway template as an example, here is a brief summary of the priniciples we&#039;ve looked at.&lt;br /&gt;
=== Customise the Component Output ===&lt;br /&gt;
&lt;br /&gt;
To override a component layout (for example the default layout in the article view), copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about [[#Component Output Types and Layout Override|component output]].&lt;br /&gt;
&lt;br /&gt;
=== Customise the Module Output ===&lt;br /&gt;
&lt;br /&gt;
To override a module layout (for example the Latest News module using the rhuk_milkyway template), copy:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about [[#Module Layout Overrides|module output]].&lt;br /&gt;
&lt;br /&gt;
=== Add New Module Styles ===&lt;br /&gt;
&lt;br /&gt;
To add new module styles (chrome), add them to the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
Read more about [[#Module Chrome|module chrome]].&lt;br /&gt;
&lt;br /&gt;
=== Customise the Pagination Links ===&lt;br /&gt;
&lt;br /&gt;
To customise the way the items-per-page selector and pagination links display, edit the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
Read more about [[#Pagination Links Overrides|pagination]].&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.5, through the use of an MVC paradigm has greatly improved the flexibility that is afforded to Web site designers.  By way of a few simple principles, like copying certain files to certain places in your template, the designer is able to override almost all of the output generated by &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If you have any questions relating to output overrides please let us know so that we can improve this tutorial.&lt;br /&gt;
&lt;br /&gt;
If you have translated this article into another language, please let us know.&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8981</id>
		<title>Understanding Output Overrides</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8981"/>
		<updated>2008-07-05T14:27:27Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Customise the Module Output */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Understanding Output Overrides in &amp;quot;Joomla!&amp;quot; 1.5 =&lt;br /&gt;
Written by Andrew Eddie&lt;br /&gt;
&lt;br /&gt;
This was Developer Blog post by Andrew, initially copied to the wiki with minor edits by Alan Langford. This is still a work in progress.&lt;br /&gt;
== Introduction ==&lt;br /&gt;
There are many competing requirements for web designers ranging from accessibility to legislative to personal preferences.  Rather than trying to over-parameterise views, or trying to aim for some sort of line of best fit, or worse, sticking its head in the sand, &amp;quot;Joomla!&amp;quot; has added the potential for the designer to take over control of virtually all of the output that is generated.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; has been criticized by some for not giving due attention to accessibility or being archaic in their approach to web standards. However with 1.5, the responsibility, but more importantly the power is back in the designer&#039;s hands.&lt;br /&gt;
&lt;br /&gt;
In addition, except for files that are provided in the &amp;quot;Joomla!&amp;quot; distribution itself, these methods for customisation eliminate the need for designers and developers to &amp;quot;hack&amp;quot; core files that could change when the site is updated to a new version.  Because they are contained within the template, they can be deployed to the Web site without having to worry about changes being accidentally overwritten when your System Administrator upgrades the site.&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to introduce the how fours areas of the output of &amp;quot;Joomla!&amp;quot; are able to be customised by the template designer.&lt;br /&gt;
&lt;br /&gt;
Not interested in all the theory?  Jump straight to the cheat sheet.&lt;br /&gt;
== MVC 101 ==&lt;br /&gt;
MVC can be a scary acronym.  It stands for Model-View-Controller and the concepts behind MVC are responsible for the extra flexibility that is now afforded to the designer.  While parts of the theory can be rather involved and complicated, the only part that the designer need worry about is the V for View.  This is the part that is concerned with output.&lt;br /&gt;
&lt;br /&gt;
Different extensions display output in different ways.&lt;br /&gt;
&lt;br /&gt;
Components, as you would already know, are fairly complex and have the ability to display different information in different ways.  For example, the Articles Component (com_content) is able to display a single article, or articles in a category, or categories in a section.  Each of the ways of representing the different types of data (an article, or a category, or a section) is called a &amp;quot;view&amp;quot; (this comes from our MVC terminology).  Most components will have many views.  However, the view doesn&#039;t actually display the output.  This is left up to what we call a &amp;quot;layout&amp;quot; and it is possible for a view to have a variety of layouts.&lt;br /&gt;
&lt;br /&gt;
The main thing to remember here is that components can have multiple views, and each view can have one or more layouts.  Each view assembles a fixed set of information, but each layout can display that information in different ways.  For example, the Category view in the Articles component assembles a number of articles.  These articles could be displayed in a list or in a table (and probably other ways as well).  So this view may have a &amp;quot;list&amp;quot; layout and a &amp;quot;table&amp;quot; layout to choose from.&lt;br /&gt;
&lt;br /&gt;
Modules, on the other hand, are very simple.  They generally display one thing one way.  Modules don&#039;t really have views but they do support a layout.  Some developers might even support a choice of layout through module parameters.&lt;br /&gt;
=== Template versus Layout ===&lt;br /&gt;
&lt;br /&gt;
It is very important to distinguish between the role of template and the role of layouts.  The template sets up a structural framework for the page of the Web site.  Within this framework are positions for modules and a component to display.  What actually gets displayed is governed by the module layout, or the combination of view and layout in the case of the component.&lt;br /&gt;
&lt;br /&gt;
The following image shows the structural layout of a typical &amp;quot;Joomla!&amp;quot; template (rhuk_milkyway, the default for 1.5).  The module positions are displayed by adding tp=1 to the URL (eg, index.php?tp=1).  You can clearly see where the module output is contained within the overall template, as well as the main component output starting in the lower-centre region.  However, what is actually output in those regions, is controlled by the layouts.&lt;br /&gt;
&lt;br /&gt;
[[Image:FrontpageTemplatePositions.png|Typical Joomla! screenshot with template positions shown.]]&lt;br /&gt;
&lt;br /&gt;
=== Ancillary Customisation ===&lt;br /&gt;
&lt;br /&gt;
While not strictly related to the MVC, there are two other important areas to consider when looking at customising the output of &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In addition to layouts, modules have what we call &amp;quot;chrome&amp;quot;.  Chrome is the style with which a module is to display.  Most developers, designers and probably some end-users will be familiar with the different built-in styles for modules (raw, xhtml, etc).  It is also possible to define your own chrome styles for modules depending on the designer result.  For example, you could design a chrome to display all the modules in a particular position in a fancy Javascript collapsing blind arrangement.&lt;br /&gt;
&lt;br /&gt;
In the screenshot above, you can just make out the names of some of the built-in module chrome used (rounded, none and xhtml).&lt;br /&gt;
&lt;br /&gt;
The second area has to do with controlling the pagination controls when viewing lists of data.  We will look at that in more detail later.&lt;br /&gt;
== Component Output Types and Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
To understand layout overrides we must first understand the file structure of a component.  While there are many parts to a component, all fulfilling different roles and responsibilities, we want to look just in the /views/ directory.  Here is the partial structure for two of the com_content views:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/components&lt;br /&gt;
  /com_content&lt;br /&gt;
	/views&lt;br /&gt;
	  /articles&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  default.php (this is a layout)&lt;br /&gt;
		  form.php	(this is a layout)&lt;br /&gt;
		view.html.php (this is the view that outputs the HTML)&lt;br /&gt;
		view.pdf.php  (this is the view that outputs the PDF)&lt;br /&gt;
	  /category&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  blog.php	   (layout)&lt;br /&gt;
		  blog_items.php (a sub-layout&lt;br /&gt;
		  default.php	(layout)&lt;br /&gt;
		view.html.php	(HTML view)&lt;br /&gt;
		view.feed.php	(RSS feed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
So what you see here is that under the /views/ directory, each view is placed in a directory of its own.  The content component actually has three other views not shown: archive, frontpage and section.&lt;br /&gt;
=== Output Types ===&lt;br /&gt;
Under the /articles/ directory we have a number of files.  There is almost always a file called view.html.php.  This is what we call the view file, but there can be more than one depending on the type of output to produce.  It has a specific naming convention, view.output_type.php, where the output type can be html, feed, pdf, raw or error (for more information see JDocument in the API reference and look in the directory /libraries/joomla/document/).  What this means is when we want html output for this particular view, the view.html.php file is used.  When we want the RSS output, the view.feed.php file is used.&lt;br /&gt;
&lt;br /&gt;
The affect of these different output types is most apparent when the Global Configuration setting for Search Engine Friendly URLs is set to Yes, Use Apache mod_rewrite is set to Yes, and Add suffix to URLs is also set to Yes.  When this is done, the site URLs will look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://domain/sports.html&lt;br /&gt;
http://domain/sports.feed&lt;br /&gt;
http://domain/sports/rowing.html&lt;br /&gt;
http://domain/sports/rowing.pdf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The exact URL will vary depending on how you set up your site but the point here is to show that sports.html will use the category view&#039;s view.html.php file to, and that sports.feed will display the RSS feed for the category using view.feed.php.  It should be noted that you cannot currently customise feed or PDF output types.  However, you can customise the html output type and this is where layouts come into play.&lt;br /&gt;
&lt;br /&gt;
=== Layouts ===&lt;br /&gt;
Under the view directory there is a /tmpl/ directory in which the layout files reside.  Each PHP file in this directory represents a layout.  For example, article/tmpl/default.php is the default layout for an article whereas article/tmpl/form.php is the edit form for an article; category/tmpl/default.php is the default layout for a category whereas category/tmpl/blog.php displays the list of article differently.&lt;br /&gt;
&lt;br /&gt;
The relationship between component views and layout is most plainly seen when adding a new menu item.  The next screenshot represents the typical display of the New Menu Item page.  Having clicked on Articles (which represents com_content), the tree expands to show the list of views and each layout within the view.&lt;br /&gt;
&lt;br /&gt;
[[Image:Menu_item_type_articles.png|Screenshot of creating a new menu item fro an article.]]&lt;br /&gt;
&lt;br /&gt;
You will notice that while there are extra files in some of the /tmpl/ directories (like pagebreak.php in the article view), they are missing from the list.  This is due to instructions in the XML file for the layout (for example, pagebreak.xml) to hide the layout (or even the view) from the menu item list.  However, this is another broad topic which will be covered in another tutorial.&lt;br /&gt;
&lt;br /&gt;
Armed with all that knowledge of how all the parts relate to each other, we are now ready to actually create our layout overrides.&lt;br /&gt;
&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
Layout overrides only work within the active template and are located under the /html/ directory in the template.  For example, the overrides for rhuk_milkyway are located under /templates/rhuk_milkyway/html/, for the JA Purity template under /templates/ja_purity/html/ and for Beez under /templates/beez/html/.&lt;br /&gt;
&lt;br /&gt;
It is important to understand that if you create overrides in one template, they will not be available in other templates.  For example, rhuk_milkyway has no component layout overrides at all.  When you use this template you are seeing the raw output from all components.  When you use the Beez template, almost every piece of component output is being controlled by the layout overrides in the template.  JA Purity is in between having overrides for some components and only some views of those components.&lt;br /&gt;
&lt;br /&gt;
The layout overrides must be placed in particular way.  Using Beez as an example you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /com_content	(this directory matches the component directory name)&lt;br /&gt;
		/articles	 (this directory matches the view directory name)&lt;br /&gt;
		  default.php (this file matches the layout file name)&lt;br /&gt;
		  form.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure for component overrides is quite simple: /html/com_component_name/view_name/layout_file_name.php.  Let&#039;s look at a few examples.&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any components.  If we want to override the default layout for an article, first we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the appropriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
If we wanted to override the blog layout in the category view, we would copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog.php&lt;br /&gt;
&lt;br /&gt;
Once the files are copied, you are free to customise these files as much or as little as required or desired.  You do not have to honour parameter settings if you don&#039;t want to.&lt;br /&gt;
=== Overriding Sub-Layouts ===&lt;br /&gt;
&lt;br /&gt;
In some views you will see that some of the layouts have a group of files that start with the same name.  The category view has an example of this.  The blog layout actually has three parts: the main layout file blog.php and two sub-layout files, blog_item.php and blog_links.php.  You can see where these sub-layouts are loaded in the blog.php file using the loadTemplate method, for example:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;item&#039;);&lt;br /&gt;
// or&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;links&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
When loading sub-layouts, the view already knows what layout you are in, so you don&#039;t have to provide the prefix (that is, you load just &#039;item&#039;, not &#039;blog_item&#039;).&lt;br /&gt;
&lt;br /&gt;
What is important to note here is that it is possible to override just a sub-layout without copying the whole set of files.  For example, if you were happy with the &amp;quot;Joomla!&amp;quot; default output for the blog layout, but just wanted to customise the item sub-layout, you could just copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog_item.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog_item.php&lt;br /&gt;
&lt;br /&gt;
When &amp;quot;Joomla!&amp;quot; is parsing the view, it will automatically know to load blog.php from com_content natively and blog_item.php from your template overrides.&lt;br /&gt;
== Module Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
Modules, like components, are set up in a particular directory structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/modules&lt;br /&gt;
  /mod_latest_news&lt;br /&gt;
	/tmpl&lt;br /&gt;
	  default.php	   (the layout)&lt;br /&gt;
	helper.php		  (a helper file containing data logic)&lt;br /&gt;
	mod_latest_news.php (the main module file)&lt;br /&gt;
	mod_latest_news.xml (the installation XML file)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Similar to components, under the main module directory (in the example, mod_latest_news) there is a /tmpl/ directory.  There is usually only one layout file but depending on who wrote the module, and how it is written, there could be more.&lt;br /&gt;
&lt;br /&gt;
As for components, the layout override for a module must be placed in particular way.  Using Beez as an example again, you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /mod_latest_news.php (this directory matches the module directory name)&lt;br /&gt;
		default.php		(this file matches the layout file name)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The structure for module overrides is again quite simple: /html/mod_module_name/layout_file_name.php.&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any modules.  If we want to override the default layout for Latest News module, we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the approriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
You need to take a little care with overriding module layout because there are a number of different ways that modules can or have been designed so you need to treat each one individually.&lt;br /&gt;
== Module Chrome ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.0 had a number of fixed styles that could display a list of modules in a particular position.  These where represented by numbers:&lt;br /&gt;
&lt;br /&gt;
* 0 (the default) displayed modules in a vertical table&lt;br /&gt;
* 1 displayed them in a horizontal table&lt;br /&gt;
* -1 displayed the raw module output&lt;br /&gt;
* -2 displayed the modules in a XHTML compatible format with the title in a H3 tag.&lt;br /&gt;
* -3 displayed modules in a set of nested DIVs that allowed for rounded-corner techniques&lt;br /&gt;
&lt;br /&gt;
It was a great system except for two things:&lt;br /&gt;
&lt;br /&gt;
# Nobody could remember which number was which, and&lt;br /&gt;
# You couldn&#039;t expand on the styles.&lt;br /&gt;
&lt;br /&gt;
Well, in 1.5, the numbers are still recognised, but more commonly the style is represented as a word.  As well as that, the syntax for displaying a module position was changed.  For example, this snippet displays each module in the left position in the xhtml style:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;jdoc:include type=&amp;quot;modules&amp;quot; name=&amp;quot;left&amp;quot; style=&amp;quot;xhtml&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The built-in styles that are now available are:&lt;br /&gt;
&lt;br /&gt;
* table (was 0 and is the default)&lt;br /&gt;
* horz (was 1)&lt;br /&gt;
* none (was -1)&lt;br /&gt;
* xhtml (was -2)&lt;br /&gt;
* rounded (was -3)&lt;br /&gt;
* outline (new - used to preview module positions - see screenshot above)&lt;br /&gt;
&lt;br /&gt;
In the source code, these styles are actually referred to ask &amp;quot;chrome&amp;quot;.  The default chrome can actually be found in the system template provided in the default &amp;quot;Joomla!&amp;quot; install:&lt;br /&gt;
&lt;br /&gt;
/templates/system/html/modules.php&lt;br /&gt;
&lt;br /&gt;
This file is maintained by the project so you should never modify it directly otherwise there is a risk that you will loose your changes if and when you upgrade your &amp;quot;Joomla!&amp;quot; installation.&lt;br /&gt;
&lt;br /&gt;
To create your own chrome, or module styles, all you need to do is create or edit modules.php under the templates /html/ directory (this is the same directory we have been talking about for component and module layout overrides).&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template actually does provide some extra chrome as an example (it provides and new example style called &amp;quot;slider&amp;quot;).  This can be found in the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
To create your own chrome is really easy.  Let&#039;s look at ficticious example that displays the module in a Definition List (a set of DL&#039;s, DT&#039;s and DD&#039;s).&lt;br /&gt;
&lt;br /&gt;
Just add the following function to the /html/modules.php file in your default template directory (create it if it does not exist):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * Module chrome that wraps the module in a definition list&lt;br /&gt;
 */&lt;br /&gt;
function modChrome_dlist($module, &amp;amp;$params, &amp;amp;$attribs)&lt;br /&gt;
{ ?&amp;gt;&lt;br /&gt;
	&amp;lt;dl class=&amp;quot;&amp;lt;?php echo $params-&amp;gt;get(&#039;moduleclass_sfx&#039;); ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;?php if ($module-&amp;gt;showtitle != 0) : ?&amp;gt;&lt;br /&gt;
		&amp;lt;dt&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;title; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dt&amp;gt;&lt;br /&gt;
	&amp;lt;?php endif; ?&amp;gt;&lt;br /&gt;
		&amp;lt;dd&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;content; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dd&amp;gt;&lt;br /&gt;
	&amp;lt;/dl&amp;gt;&lt;br /&gt;
	&amp;lt;?php&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We will be calling the style &amp;quot;dlist&amp;quot;, so the name of the function needs to be modChrome_dlist.&lt;br /&gt;
&lt;br /&gt;
The function must take the three arguments as shown for the module object, the module parameters, and lastly the $attribs is an array of all the attributes in the jdoc XML tag.&lt;br /&gt;
&lt;br /&gt;
There are three main properties in the module object to be concerned with:&lt;br /&gt;
&lt;br /&gt;
* showtitle tells you whether to show the title of the module of not&lt;br /&gt;
* title is the title of the module&lt;br /&gt;
* content is the output of the module (from its layout)&lt;br /&gt;
&lt;br /&gt;
This is a very simple case and you can of course design more complex styles, possibly using custom atrributes in the XML tag.&lt;br /&gt;
== Pagination Links Overrides ==&lt;br /&gt;
&lt;br /&gt;
The final override we will look at is the pagination override.  This override can control the display of items-per-page and the pagination links that are used with lists of information, as shown in the following screenshot.&lt;br /&gt;
&lt;br /&gt;
[[Image:Article_list_pagination.png|Typical Joomla! page showing a paginated list.]]&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template provides a well commented example for this override.  The file is found here:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
When the pagination list is required, &amp;quot;Joomla!&amp;quot; will look for this file in the default templates.  If it is found it will be loaded and the display functions it contains will be used.&lt;br /&gt;
&lt;br /&gt;
There are four functions that can be used:&lt;br /&gt;
&lt;br /&gt;
pagination_list_footer&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the select list for the number of items to display per page.&lt;br /&gt;
&lt;br /&gt;
pagination_list_render&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the list of page number links as well at the Start, End, Previous and Next links.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the links to other page numbers other than the &amp;quot;current&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the current page number, usually not hyperlinked.&lt;br /&gt;
&lt;br /&gt;
== Cheat Sheet ==&lt;br /&gt;
&lt;br /&gt;
Using the rhuk_milkyway template as an example, here is a brief summary of the priniciples we&#039;ve looked at.&lt;br /&gt;
=== Customise the Component Output ===&lt;br /&gt;
&lt;br /&gt;
To override a component layout (for example the default layout in the article view), copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about component output.&lt;br /&gt;
=== Customise the Module Output ===&lt;br /&gt;
&lt;br /&gt;
To override a module layout (for example the Latest News module using the rhuk_milkyway template), copy:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about [[#Module Layout Overrides|module output]].&lt;br /&gt;
&lt;br /&gt;
=== Add New Module Styles ===&lt;br /&gt;
&lt;br /&gt;
To add new module styles (chrome), add them to the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
Read more about [[#Module Chrome|module chrome]].&lt;br /&gt;
&lt;br /&gt;
=== Customise the Pagination Links ===&lt;br /&gt;
&lt;br /&gt;
To customise the way the items-per-page selector and pagination links display, edit the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
Read more about [[#Pagination Links Overrides|pagination]].&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.5, through the use of an MVC paradigm has greatly improved the flexibility that is afforded to Web site designers.  By way of a few simple principles, like copying certain files to certain places in your template, the designer is able to override almost all of the output generated by &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If you have any questions relating to output overrides please let us know so that we can improve this tutorial.&lt;br /&gt;
&lt;br /&gt;
If you have translated this article into another language, please let us know.&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8980</id>
		<title>Understanding Output Overrides</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8980"/>
		<updated>2008-07-05T14:25:51Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Add New Module Styles */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Understanding Output Overrides in &amp;quot;Joomla!&amp;quot; 1.5 =&lt;br /&gt;
Written by Andrew Eddie&lt;br /&gt;
&lt;br /&gt;
This was Developer Blog post by Andrew, initially copied to the wiki with minor edits by Alan Langford. This is still a work in progress.&lt;br /&gt;
== Introduction ==&lt;br /&gt;
There are many competing requirements for web designers ranging from accessibility to legislative to personal preferences.  Rather than trying to over-parameterise views, or trying to aim for some sort of line of best fit, or worse, sticking its head in the sand, &amp;quot;Joomla!&amp;quot; has added the potential for the designer to take over control of virtually all of the output that is generated.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; has been criticized by some for not giving due attention to accessibility or being archaic in their approach to web standards. However with 1.5, the responsibility, but more importantly the power is back in the designer&#039;s hands.&lt;br /&gt;
&lt;br /&gt;
In addition, except for files that are provided in the &amp;quot;Joomla!&amp;quot; distribution itself, these methods for customisation eliminate the need for designers and developers to &amp;quot;hack&amp;quot; core files that could change when the site is updated to a new version.  Because they are contained within the template, they can be deployed to the Web site without having to worry about changes being accidentally overwritten when your System Administrator upgrades the site.&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to introduce the how fours areas of the output of &amp;quot;Joomla!&amp;quot; are able to be customised by the template designer.&lt;br /&gt;
&lt;br /&gt;
Not interested in all the theory?  Jump straight to the cheat sheet.&lt;br /&gt;
== MVC 101 ==&lt;br /&gt;
MVC can be a scary acronym.  It stands for Model-View-Controller and the concepts behind MVC are responsible for the extra flexibility that is now afforded to the designer.  While parts of the theory can be rather involved and complicated, the only part that the designer need worry about is the V for View.  This is the part that is concerned with output.&lt;br /&gt;
&lt;br /&gt;
Different extensions display output in different ways.&lt;br /&gt;
&lt;br /&gt;
Components, as you would already know, are fairly complex and have the ability to display different information in different ways.  For example, the Articles Component (com_content) is able to display a single article, or articles in a category, or categories in a section.  Each of the ways of representing the different types of data (an article, or a category, or a section) is called a &amp;quot;view&amp;quot; (this comes from our MVC terminology).  Most components will have many views.  However, the view doesn&#039;t actually display the output.  This is left up to what we call a &amp;quot;layout&amp;quot; and it is possible for a view to have a variety of layouts.&lt;br /&gt;
&lt;br /&gt;
The main thing to remember here is that components can have multiple views, and each view can have one or more layouts.  Each view assembles a fixed set of information, but each layout can display that information in different ways.  For example, the Category view in the Articles component assembles a number of articles.  These articles could be displayed in a list or in a table (and probably other ways as well).  So this view may have a &amp;quot;list&amp;quot; layout and a &amp;quot;table&amp;quot; layout to choose from.&lt;br /&gt;
&lt;br /&gt;
Modules, on the other hand, are very simple.  They generally display one thing one way.  Modules don&#039;t really have views but they do support a layout.  Some developers might even support a choice of layout through module parameters.&lt;br /&gt;
=== Template versus Layout ===&lt;br /&gt;
&lt;br /&gt;
It is very important to distinguish between the role of template and the role of layouts.  The template sets up a structural framework for the page of the Web site.  Within this framework are positions for modules and a component to display.  What actually gets displayed is governed by the module layout, or the combination of view and layout in the case of the component.&lt;br /&gt;
&lt;br /&gt;
The following image shows the structural layout of a typical &amp;quot;Joomla!&amp;quot; template (rhuk_milkyway, the default for 1.5).  The module positions are displayed by adding tp=1 to the URL (eg, index.php?tp=1).  You can clearly see where the module output is contained within the overall template, as well as the main component output starting in the lower-centre region.  However, what is actually output in those regions, is controlled by the layouts.&lt;br /&gt;
&lt;br /&gt;
[[Image:FrontpageTemplatePositions.png|Typical Joomla! screenshot with template positions shown.]]&lt;br /&gt;
&lt;br /&gt;
=== Ancillary Customisation ===&lt;br /&gt;
&lt;br /&gt;
While not strictly related to the MVC, there are two other important areas to consider when looking at customising the output of &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In addition to layouts, modules have what we call &amp;quot;chrome&amp;quot;.  Chrome is the style with which a module is to display.  Most developers, designers and probably some end-users will be familiar with the different built-in styles for modules (raw, xhtml, etc).  It is also possible to define your own chrome styles for modules depending on the designer result.  For example, you could design a chrome to display all the modules in a particular position in a fancy Javascript collapsing blind arrangement.&lt;br /&gt;
&lt;br /&gt;
In the screenshot above, you can just make out the names of some of the built-in module chrome used (rounded, none and xhtml).&lt;br /&gt;
&lt;br /&gt;
The second area has to do with controlling the pagination controls when viewing lists of data.  We will look at that in more detail later.&lt;br /&gt;
== Component Output Types and Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
To understand layout overrides we must first understand the file structure of a component.  While there are many parts to a component, all fulfilling different roles and responsibilities, we want to look just in the /views/ directory.  Here is the partial structure for two of the com_content views:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/components&lt;br /&gt;
  /com_content&lt;br /&gt;
	/views&lt;br /&gt;
	  /articles&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  default.php (this is a layout)&lt;br /&gt;
		  form.php	(this is a layout)&lt;br /&gt;
		view.html.php (this is the view that outputs the HTML)&lt;br /&gt;
		view.pdf.php  (this is the view that outputs the PDF)&lt;br /&gt;
	  /category&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  blog.php	   (layout)&lt;br /&gt;
		  blog_items.php (a sub-layout&lt;br /&gt;
		  default.php	(layout)&lt;br /&gt;
		view.html.php	(HTML view)&lt;br /&gt;
		view.feed.php	(RSS feed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
So what you see here is that under the /views/ directory, each view is placed in a directory of its own.  The content component actually has three other views not shown: archive, frontpage and section.&lt;br /&gt;
=== Output Types ===&lt;br /&gt;
Under the /articles/ directory we have a number of files.  There is almost always a file called view.html.php.  This is what we call the view file, but there can be more than one depending on the type of output to produce.  It has a specific naming convention, view.output_type.php, where the output type can be html, feed, pdf, raw or error (for more information see JDocument in the API reference and look in the directory /libraries/joomla/document/).  What this means is when we want html output for this particular view, the view.html.php file is used.  When we want the RSS output, the view.feed.php file is used.&lt;br /&gt;
&lt;br /&gt;
The affect of these different output types is most apparent when the Global Configuration setting for Search Engine Friendly URLs is set to Yes, Use Apache mod_rewrite is set to Yes, and Add suffix to URLs is also set to Yes.  When this is done, the site URLs will look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://domain/sports.html&lt;br /&gt;
http://domain/sports.feed&lt;br /&gt;
http://domain/sports/rowing.html&lt;br /&gt;
http://domain/sports/rowing.pdf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The exact URL will vary depending on how you set up your site but the point here is to show that sports.html will use the category view&#039;s view.html.php file to, and that sports.feed will display the RSS feed for the category using view.feed.php.  It should be noted that you cannot currently customise feed or PDF output types.  However, you can customise the html output type and this is where layouts come into play.&lt;br /&gt;
&lt;br /&gt;
=== Layouts ===&lt;br /&gt;
Under the view directory there is a /tmpl/ directory in which the layout files reside.  Each PHP file in this directory represents a layout.  For example, article/tmpl/default.php is the default layout for an article whereas article/tmpl/form.php is the edit form for an article; category/tmpl/default.php is the default layout for a category whereas category/tmpl/blog.php displays the list of article differently.&lt;br /&gt;
&lt;br /&gt;
The relationship between component views and layout is most plainly seen when adding a new menu item.  The next screenshot represents the typical display of the New Menu Item page.  Having clicked on Articles (which represents com_content), the tree expands to show the list of views and each layout within the view.&lt;br /&gt;
&lt;br /&gt;
[[Image:Menu_item_type_articles.png|Screenshot of creating a new menu item fro an article.]]&lt;br /&gt;
&lt;br /&gt;
You will notice that while there are extra files in some of the /tmpl/ directories (like pagebreak.php in the article view), they are missing from the list.  This is due to instructions in the XML file for the layout (for example, pagebreak.xml) to hide the layout (or even the view) from the menu item list.  However, this is another broad topic which will be covered in another tutorial.&lt;br /&gt;
&lt;br /&gt;
Armed with all that knowledge of how all the parts relate to each other, we are now ready to actually create our layout overrides.&lt;br /&gt;
&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
Layout overrides only work within the active template and are located under the /html/ directory in the template.  For example, the overrides for rhuk_milkyway are located under /templates/rhuk_milkyway/html/, for the JA Purity template under /templates/ja_purity/html/ and for Beez under /templates/beez/html/.&lt;br /&gt;
&lt;br /&gt;
It is important to understand that if you create overrides in one template, they will not be available in other templates.  For example, rhuk_milkyway has no component layout overrides at all.  When you use this template you are seeing the raw output from all components.  When you use the Beez template, almost every piece of component output is being controlled by the layout overrides in the template.  JA Purity is in between having overrides for some components and only some views of those components.&lt;br /&gt;
&lt;br /&gt;
The layout overrides must be placed in particular way.  Using Beez as an example you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /com_content	(this directory matches the component directory name)&lt;br /&gt;
		/articles	 (this directory matches the view directory name)&lt;br /&gt;
		  default.php (this file matches the layout file name)&lt;br /&gt;
		  form.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure for component overrides is quite simple: /html/com_component_name/view_name/layout_file_name.php.  Let&#039;s look at a few examples.&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any components.  If we want to override the default layout for an article, first we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the appropriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
If we wanted to override the blog layout in the category view, we would copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog.php&lt;br /&gt;
&lt;br /&gt;
Once the files are copied, you are free to customise these files as much or as little as required or desired.  You do not have to honour parameter settings if you don&#039;t want to.&lt;br /&gt;
=== Overriding Sub-Layouts ===&lt;br /&gt;
&lt;br /&gt;
In some views you will see that some of the layouts have a group of files that start with the same name.  The category view has an example of this.  The blog layout actually has three parts: the main layout file blog.php and two sub-layout files, blog_item.php and blog_links.php.  You can see where these sub-layouts are loaded in the blog.php file using the loadTemplate method, for example:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;item&#039;);&lt;br /&gt;
// or&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;links&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
When loading sub-layouts, the view already knows what layout you are in, so you don&#039;t have to provide the prefix (that is, you load just &#039;item&#039;, not &#039;blog_item&#039;).&lt;br /&gt;
&lt;br /&gt;
What is important to note here is that it is possible to override just a sub-layout without copying the whole set of files.  For example, if you were happy with the &amp;quot;Joomla!&amp;quot; default output for the blog layout, but just wanted to customise the item sub-layout, you could just copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog_item.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog_item.php&lt;br /&gt;
&lt;br /&gt;
When &amp;quot;Joomla!&amp;quot; is parsing the view, it will automatically know to load blog.php from com_content natively and blog_item.php from your template overrides.&lt;br /&gt;
== Module Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
Modules, like components, are set up in a particular directory structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/modules&lt;br /&gt;
  /mod_latest_news&lt;br /&gt;
	/tmpl&lt;br /&gt;
	  default.php	   (the layout)&lt;br /&gt;
	helper.php		  (a helper file containing data logic)&lt;br /&gt;
	mod_latest_news.php (the main module file)&lt;br /&gt;
	mod_latest_news.xml (the installation XML file)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Similar to components, under the main module directory (in the example, mod_latest_news) there is a /tmpl/ directory.  There is usually only one layout file but depending on who wrote the module, and how it is written, there could be more.&lt;br /&gt;
&lt;br /&gt;
As for components, the layout override for a module must be placed in particular way.  Using Beez as an example again, you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /mod_latest_news.php (this directory matches the module directory name)&lt;br /&gt;
		default.php		(this file matches the layout file name)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The structure for module overrides is again quite simple: /html/mod_module_name/layout_file_name.php.&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any modules.  If we want to override the default layout for Latest News module, we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the approriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
You need to take a little care with overriding module layout because there are a number of different ways that modules can or have been designed so you need to treat each one individually.&lt;br /&gt;
== Module Chrome ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.0 had a number of fixed styles that could display a list of modules in a particular position.  These where represented by numbers:&lt;br /&gt;
&lt;br /&gt;
* 0 (the default) displayed modules in a vertical table&lt;br /&gt;
* 1 displayed them in a horizontal table&lt;br /&gt;
* -1 displayed the raw module output&lt;br /&gt;
* -2 displayed the modules in a XHTML compatible format with the title in a H3 tag.&lt;br /&gt;
* -3 displayed modules in a set of nested DIVs that allowed for rounded-corner techniques&lt;br /&gt;
&lt;br /&gt;
It was a great system except for two things:&lt;br /&gt;
&lt;br /&gt;
# Nobody could remember which number was which, and&lt;br /&gt;
# You couldn&#039;t expand on the styles.&lt;br /&gt;
&lt;br /&gt;
Well, in 1.5, the numbers are still recognised, but more commonly the style is represented as a word.  As well as that, the syntax for displaying a module position was changed.  For example, this snippet displays each module in the left position in the xhtml style:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;jdoc:include type=&amp;quot;modules&amp;quot; name=&amp;quot;left&amp;quot; style=&amp;quot;xhtml&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The built-in styles that are now available are:&lt;br /&gt;
&lt;br /&gt;
* table (was 0 and is the default)&lt;br /&gt;
* horz (was 1)&lt;br /&gt;
* none (was -1)&lt;br /&gt;
* xhtml (was -2)&lt;br /&gt;
* rounded (was -3)&lt;br /&gt;
* outline (new - used to preview module positions - see screenshot above)&lt;br /&gt;
&lt;br /&gt;
In the source code, these styles are actually referred to ask &amp;quot;chrome&amp;quot;.  The default chrome can actually be found in the system template provided in the default &amp;quot;Joomla!&amp;quot; install:&lt;br /&gt;
&lt;br /&gt;
/templates/system/html/modules.php&lt;br /&gt;
&lt;br /&gt;
This file is maintained by the project so you should never modify it directly otherwise there is a risk that you will loose your changes if and when you upgrade your &amp;quot;Joomla!&amp;quot; installation.&lt;br /&gt;
&lt;br /&gt;
To create your own chrome, or module styles, all you need to do is create or edit modules.php under the templates /html/ directory (this is the same directory we have been talking about for component and module layout overrides).&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template actually does provide some extra chrome as an example (it provides and new example style called &amp;quot;slider&amp;quot;).  This can be found in the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
To create your own chrome is really easy.  Let&#039;s look at ficticious example that displays the module in a Definition List (a set of DL&#039;s, DT&#039;s and DD&#039;s).&lt;br /&gt;
&lt;br /&gt;
Just add the following function to the /html/modules.php file in your default template directory (create it if it does not exist):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * Module chrome that wraps the module in a definition list&lt;br /&gt;
 */&lt;br /&gt;
function modChrome_dlist($module, &amp;amp;$params, &amp;amp;$attribs)&lt;br /&gt;
{ ?&amp;gt;&lt;br /&gt;
	&amp;lt;dl class=&amp;quot;&amp;lt;?php echo $params-&amp;gt;get(&#039;moduleclass_sfx&#039;); ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;?php if ($module-&amp;gt;showtitle != 0) : ?&amp;gt;&lt;br /&gt;
		&amp;lt;dt&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;title; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dt&amp;gt;&lt;br /&gt;
	&amp;lt;?php endif; ?&amp;gt;&lt;br /&gt;
		&amp;lt;dd&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;content; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dd&amp;gt;&lt;br /&gt;
	&amp;lt;/dl&amp;gt;&lt;br /&gt;
	&amp;lt;?php&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We will be calling the style &amp;quot;dlist&amp;quot;, so the name of the function needs to be modChrome_dlist.&lt;br /&gt;
&lt;br /&gt;
The function must take the three arguments as shown for the module object, the module parameters, and lastly the $attribs is an array of all the attributes in the jdoc XML tag.&lt;br /&gt;
&lt;br /&gt;
There are three main properties in the module object to be concerned with:&lt;br /&gt;
&lt;br /&gt;
* showtitle tells you whether to show the title of the module of not&lt;br /&gt;
* title is the title of the module&lt;br /&gt;
* content is the output of the module (from its layout)&lt;br /&gt;
&lt;br /&gt;
This is a very simple case and you can of course design more complex styles, possibly using custom atrributes in the XML tag.&lt;br /&gt;
== Pagination Links Overrides ==&lt;br /&gt;
&lt;br /&gt;
The final override we will look at is the pagination override.  This override can control the display of items-per-page and the pagination links that are used with lists of information, as shown in the following screenshot.&lt;br /&gt;
&lt;br /&gt;
[[Image:Article_list_pagination.png|Typical Joomla! page showing a paginated list.]]&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template provides a well commented example for this override.  The file is found here:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
When the pagination list is required, &amp;quot;Joomla!&amp;quot; will look for this file in the default templates.  If it is found it will be loaded and the display functions it contains will be used.&lt;br /&gt;
&lt;br /&gt;
There are four functions that can be used:&lt;br /&gt;
&lt;br /&gt;
pagination_list_footer&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the select list for the number of items to display per page.&lt;br /&gt;
&lt;br /&gt;
pagination_list_render&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the list of page number links as well at the Start, End, Previous and Next links.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the links to other page numbers other than the &amp;quot;current&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the current page number, usually not hyperlinked.&lt;br /&gt;
&lt;br /&gt;
== Cheat Sheet ==&lt;br /&gt;
&lt;br /&gt;
Using the rhuk_milkyway template as an example, here is a brief summary of the priniciples we&#039;ve looked at.&lt;br /&gt;
=== Customise the Component Output ===&lt;br /&gt;
&lt;br /&gt;
To override a component layout (for example the default layout in the article view), copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about component output.&lt;br /&gt;
=== Customise the Module Output ===&lt;br /&gt;
&lt;br /&gt;
To override a module layout (for example the Latest News module using the rhuk_milkyway template), copy:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about module output.&lt;br /&gt;
=== Add New Module Styles ===&lt;br /&gt;
&lt;br /&gt;
To add new module styles (chrome), add them to the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
Read more about [[#Module Chrome|module chrome]].&lt;br /&gt;
&lt;br /&gt;
=== Customise the Pagination Links ===&lt;br /&gt;
&lt;br /&gt;
To customise the way the items-per-page selector and pagination links display, edit the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
Read more about [[#Pagination Links Overrides|pagination]].&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.5, through the use of an MVC paradigm has greatly improved the flexibility that is afforded to Web site designers.  By way of a few simple principles, like copying certain files to certain places in your template, the designer is able to override almost all of the output generated by &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If you have any questions relating to output overrides please let us know so that we can improve this tutorial.&lt;br /&gt;
&lt;br /&gt;
If you have translated this article into another language, please let us know.&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8979</id>
		<title>Understanding Output Overrides</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8979"/>
		<updated>2008-07-05T14:24:25Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Customise the Pagination Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Understanding Output Overrides in &amp;quot;Joomla!&amp;quot; 1.5 =&lt;br /&gt;
Written by Andrew Eddie&lt;br /&gt;
&lt;br /&gt;
This was Developer Blog post by Andrew, initially copied to the wiki with minor edits by Alan Langford. This is still a work in progress.&lt;br /&gt;
== Introduction ==&lt;br /&gt;
There are many competing requirements for web designers ranging from accessibility to legislative to personal preferences.  Rather than trying to over-parameterise views, or trying to aim for some sort of line of best fit, or worse, sticking its head in the sand, &amp;quot;Joomla!&amp;quot; has added the potential for the designer to take over control of virtually all of the output that is generated.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; has been criticized by some for not giving due attention to accessibility or being archaic in their approach to web standards. However with 1.5, the responsibility, but more importantly the power is back in the designer&#039;s hands.&lt;br /&gt;
&lt;br /&gt;
In addition, except for files that are provided in the &amp;quot;Joomla!&amp;quot; distribution itself, these methods for customisation eliminate the need for designers and developers to &amp;quot;hack&amp;quot; core files that could change when the site is updated to a new version.  Because they are contained within the template, they can be deployed to the Web site without having to worry about changes being accidentally overwritten when your System Administrator upgrades the site.&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to introduce the how fours areas of the output of &amp;quot;Joomla!&amp;quot; are able to be customised by the template designer.&lt;br /&gt;
&lt;br /&gt;
Not interested in all the theory?  Jump straight to the cheat sheet.&lt;br /&gt;
== MVC 101 ==&lt;br /&gt;
MVC can be a scary acronym.  It stands for Model-View-Controller and the concepts behind MVC are responsible for the extra flexibility that is now afforded to the designer.  While parts of the theory can be rather involved and complicated, the only part that the designer need worry about is the V for View.  This is the part that is concerned with output.&lt;br /&gt;
&lt;br /&gt;
Different extensions display output in different ways.&lt;br /&gt;
&lt;br /&gt;
Components, as you would already know, are fairly complex and have the ability to display different information in different ways.  For example, the Articles Component (com_content) is able to display a single article, or articles in a category, or categories in a section.  Each of the ways of representing the different types of data (an article, or a category, or a section) is called a &amp;quot;view&amp;quot; (this comes from our MVC terminology).  Most components will have many views.  However, the view doesn&#039;t actually display the output.  This is left up to what we call a &amp;quot;layout&amp;quot; and it is possible for a view to have a variety of layouts.&lt;br /&gt;
&lt;br /&gt;
The main thing to remember here is that components can have multiple views, and each view can have one or more layouts.  Each view assembles a fixed set of information, but each layout can display that information in different ways.  For example, the Category view in the Articles component assembles a number of articles.  These articles could be displayed in a list or in a table (and probably other ways as well).  So this view may have a &amp;quot;list&amp;quot; layout and a &amp;quot;table&amp;quot; layout to choose from.&lt;br /&gt;
&lt;br /&gt;
Modules, on the other hand, are very simple.  They generally display one thing one way.  Modules don&#039;t really have views but they do support a layout.  Some developers might even support a choice of layout through module parameters.&lt;br /&gt;
=== Template versus Layout ===&lt;br /&gt;
&lt;br /&gt;
It is very important to distinguish between the role of template and the role of layouts.  The template sets up a structural framework for the page of the Web site.  Within this framework are positions for modules and a component to display.  What actually gets displayed is governed by the module layout, or the combination of view and layout in the case of the component.&lt;br /&gt;
&lt;br /&gt;
The following image shows the structural layout of a typical &amp;quot;Joomla!&amp;quot; template (rhuk_milkyway, the default for 1.5).  The module positions are displayed by adding tp=1 to the URL (eg, index.php?tp=1).  You can clearly see where the module output is contained within the overall template, as well as the main component output starting in the lower-centre region.  However, what is actually output in those regions, is controlled by the layouts.&lt;br /&gt;
&lt;br /&gt;
[[Image:FrontpageTemplatePositions.png|Typical Joomla! screenshot with template positions shown.]]&lt;br /&gt;
&lt;br /&gt;
=== Ancillary Customisation ===&lt;br /&gt;
&lt;br /&gt;
While not strictly related to the MVC, there are two other important areas to consider when looking at customising the output of &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In addition to layouts, modules have what we call &amp;quot;chrome&amp;quot;.  Chrome is the style with which a module is to display.  Most developers, designers and probably some end-users will be familiar with the different built-in styles for modules (raw, xhtml, etc).  It is also possible to define your own chrome styles for modules depending on the designer result.  For example, you could design a chrome to display all the modules in a particular position in a fancy Javascript collapsing blind arrangement.&lt;br /&gt;
&lt;br /&gt;
In the screenshot above, you can just make out the names of some of the built-in module chrome used (rounded, none and xhtml).&lt;br /&gt;
&lt;br /&gt;
The second area has to do with controlling the pagination controls when viewing lists of data.  We will look at that in more detail later.&lt;br /&gt;
== Component Output Types and Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
To understand layout overrides we must first understand the file structure of a component.  While there are many parts to a component, all fulfilling different roles and responsibilities, we want to look just in the /views/ directory.  Here is the partial structure for two of the com_content views:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/components&lt;br /&gt;
  /com_content&lt;br /&gt;
	/views&lt;br /&gt;
	  /articles&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  default.php (this is a layout)&lt;br /&gt;
		  form.php	(this is a layout)&lt;br /&gt;
		view.html.php (this is the view that outputs the HTML)&lt;br /&gt;
		view.pdf.php  (this is the view that outputs the PDF)&lt;br /&gt;
	  /category&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  blog.php	   (layout)&lt;br /&gt;
		  blog_items.php (a sub-layout&lt;br /&gt;
		  default.php	(layout)&lt;br /&gt;
		view.html.php	(HTML view)&lt;br /&gt;
		view.feed.php	(RSS feed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
So what you see here is that under the /views/ directory, each view is placed in a directory of its own.  The content component actually has three other views not shown: archive, frontpage and section.&lt;br /&gt;
=== Output Types ===&lt;br /&gt;
Under the /articles/ directory we have a number of files.  There is almost always a file called view.html.php.  This is what we call the view file, but there can be more than one depending on the type of output to produce.  It has a specific naming convention, view.output_type.php, where the output type can be html, feed, pdf, raw or error (for more information see JDocument in the API reference and look in the directory /libraries/joomla/document/).  What this means is when we want html output for this particular view, the view.html.php file is used.  When we want the RSS output, the view.feed.php file is used.&lt;br /&gt;
&lt;br /&gt;
The affect of these different output types is most apparent when the Global Configuration setting for Search Engine Friendly URLs is set to Yes, Use Apache mod_rewrite is set to Yes, and Add suffix to URLs is also set to Yes.  When this is done, the site URLs will look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://domain/sports.html&lt;br /&gt;
http://domain/sports.feed&lt;br /&gt;
http://domain/sports/rowing.html&lt;br /&gt;
http://domain/sports/rowing.pdf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The exact URL will vary depending on how you set up your site but the point here is to show that sports.html will use the category view&#039;s view.html.php file to, and that sports.feed will display the RSS feed for the category using view.feed.php.  It should be noted that you cannot currently customise feed or PDF output types.  However, you can customise the html output type and this is where layouts come into play.&lt;br /&gt;
&lt;br /&gt;
=== Layouts ===&lt;br /&gt;
Under the view directory there is a /tmpl/ directory in which the layout files reside.  Each PHP file in this directory represents a layout.  For example, article/tmpl/default.php is the default layout for an article whereas article/tmpl/form.php is the edit form for an article; category/tmpl/default.php is the default layout for a category whereas category/tmpl/blog.php displays the list of article differently.&lt;br /&gt;
&lt;br /&gt;
The relationship between component views and layout is most plainly seen when adding a new menu item.  The next screenshot represents the typical display of the New Menu Item page.  Having clicked on Articles (which represents com_content), the tree expands to show the list of views and each layout within the view.&lt;br /&gt;
&lt;br /&gt;
[[Image:Menu_item_type_articles.png|Screenshot of creating a new menu item fro an article.]]&lt;br /&gt;
&lt;br /&gt;
You will notice that while there are extra files in some of the /tmpl/ directories (like pagebreak.php in the article view), they are missing from the list.  This is due to instructions in the XML file for the layout (for example, pagebreak.xml) to hide the layout (or even the view) from the menu item list.  However, this is another broad topic which will be covered in another tutorial.&lt;br /&gt;
&lt;br /&gt;
Armed with all that knowledge of how all the parts relate to each other, we are now ready to actually create our layout overrides.&lt;br /&gt;
&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
Layout overrides only work within the active template and are located under the /html/ directory in the template.  For example, the overrides for rhuk_milkyway are located under /templates/rhuk_milkyway/html/, for the JA Purity template under /templates/ja_purity/html/ and for Beez under /templates/beez/html/.&lt;br /&gt;
&lt;br /&gt;
It is important to understand that if you create overrides in one template, they will not be available in other templates.  For example, rhuk_milkyway has no component layout overrides at all.  When you use this template you are seeing the raw output from all components.  When you use the Beez template, almost every piece of component output is being controlled by the layout overrides in the template.  JA Purity is in between having overrides for some components and only some views of those components.&lt;br /&gt;
&lt;br /&gt;
The layout overrides must be placed in particular way.  Using Beez as an example you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /com_content	(this directory matches the component directory name)&lt;br /&gt;
		/articles	 (this directory matches the view directory name)&lt;br /&gt;
		  default.php (this file matches the layout file name)&lt;br /&gt;
		  form.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure for component overrides is quite simple: /html/com_component_name/view_name/layout_file_name.php.  Let&#039;s look at a few examples.&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any components.  If we want to override the default layout for an article, first we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the appropriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
If we wanted to override the blog layout in the category view, we would copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog.php&lt;br /&gt;
&lt;br /&gt;
Once the files are copied, you are free to customise these files as much or as little as required or desired.  You do not have to honour parameter settings if you don&#039;t want to.&lt;br /&gt;
=== Overriding Sub-Layouts ===&lt;br /&gt;
&lt;br /&gt;
In some views you will see that some of the layouts have a group of files that start with the same name.  The category view has an example of this.  The blog layout actually has three parts: the main layout file blog.php and two sub-layout files, blog_item.php and blog_links.php.  You can see where these sub-layouts are loaded in the blog.php file using the loadTemplate method, for example:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;item&#039;);&lt;br /&gt;
// or&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;links&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
When loading sub-layouts, the view already knows what layout you are in, so you don&#039;t have to provide the prefix (that is, you load just &#039;item&#039;, not &#039;blog_item&#039;).&lt;br /&gt;
&lt;br /&gt;
What is important to note here is that it is possible to override just a sub-layout without copying the whole set of files.  For example, if you were happy with the &amp;quot;Joomla!&amp;quot; default output for the blog layout, but just wanted to customise the item sub-layout, you could just copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog_item.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog_item.php&lt;br /&gt;
&lt;br /&gt;
When &amp;quot;Joomla!&amp;quot; is parsing the view, it will automatically know to load blog.php from com_content natively and blog_item.php from your template overrides.&lt;br /&gt;
== Module Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
Modules, like components, are set up in a particular directory structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/modules&lt;br /&gt;
  /mod_latest_news&lt;br /&gt;
	/tmpl&lt;br /&gt;
	  default.php	   (the layout)&lt;br /&gt;
	helper.php		  (a helper file containing data logic)&lt;br /&gt;
	mod_latest_news.php (the main module file)&lt;br /&gt;
	mod_latest_news.xml (the installation XML file)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Similar to components, under the main module directory (in the example, mod_latest_news) there is a /tmpl/ directory.  There is usually only one layout file but depending on who wrote the module, and how it is written, there could be more.&lt;br /&gt;
&lt;br /&gt;
As for components, the layout override for a module must be placed in particular way.  Using Beez as an example again, you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /mod_latest_news.php (this directory matches the module directory name)&lt;br /&gt;
		default.php		(this file matches the layout file name)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The structure for module overrides is again quite simple: /html/mod_module_name/layout_file_name.php.&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any modules.  If we want to override the default layout for Latest News module, we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the approriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
You need to take a little care with overriding module layout because there are a number of different ways that modules can or have been designed so you need to treat each one individually.&lt;br /&gt;
== Module Chrome ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.0 had a number of fixed styles that could display a list of modules in a particular position.  These where represented by numbers:&lt;br /&gt;
&lt;br /&gt;
* 0 (the default) displayed modules in a vertical table&lt;br /&gt;
* 1 displayed them in a horizontal table&lt;br /&gt;
* -1 displayed the raw module output&lt;br /&gt;
* -2 displayed the modules in a XHTML compatible format with the title in a H3 tag.&lt;br /&gt;
* -3 displayed modules in a set of nested DIVs that allowed for rounded-corner techniques&lt;br /&gt;
&lt;br /&gt;
It was a great system except for two things:&lt;br /&gt;
&lt;br /&gt;
# Nobody could remember which number was which, and&lt;br /&gt;
# You couldn&#039;t expand on the styles.&lt;br /&gt;
&lt;br /&gt;
Well, in 1.5, the numbers are still recognised, but more commonly the style is represented as a word.  As well as that, the syntax for displaying a module position was changed.  For example, this snippet displays each module in the left position in the xhtml style:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;jdoc:include type=&amp;quot;modules&amp;quot; name=&amp;quot;left&amp;quot; style=&amp;quot;xhtml&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The built-in styles that are now available are:&lt;br /&gt;
&lt;br /&gt;
* table (was 0 and is the default)&lt;br /&gt;
* horz (was 1)&lt;br /&gt;
* none (was -1)&lt;br /&gt;
* xhtml (was -2)&lt;br /&gt;
* rounded (was -3)&lt;br /&gt;
* outline (new - used to preview module positions - see screenshot above)&lt;br /&gt;
&lt;br /&gt;
In the source code, these styles are actually referred to ask &amp;quot;chrome&amp;quot;.  The default chrome can actually be found in the system template provided in the default &amp;quot;Joomla!&amp;quot; install:&lt;br /&gt;
&lt;br /&gt;
/templates/system/html/modules.php&lt;br /&gt;
&lt;br /&gt;
This file is maintained by the project so you should never modify it directly otherwise there is a risk that you will loose your changes if and when you upgrade your &amp;quot;Joomla!&amp;quot; installation.&lt;br /&gt;
&lt;br /&gt;
To create your own chrome, or module styles, all you need to do is create or edit modules.php under the templates /html/ directory (this is the same directory we have been talking about for component and module layout overrides).&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template actually does provide some extra chrome as an example (it provides and new example style called &amp;quot;slider&amp;quot;).  This can be found in the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
To create your own chrome is really easy.  Let&#039;s look at ficticious example that displays the module in a Definition List (a set of DL&#039;s, DT&#039;s and DD&#039;s).&lt;br /&gt;
&lt;br /&gt;
Just add the following function to the /html/modules.php file in your default template directory (create it if it does not exist):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * Module chrome that wraps the module in a definition list&lt;br /&gt;
 */&lt;br /&gt;
function modChrome_dlist($module, &amp;amp;$params, &amp;amp;$attribs)&lt;br /&gt;
{ ?&amp;gt;&lt;br /&gt;
	&amp;lt;dl class=&amp;quot;&amp;lt;?php echo $params-&amp;gt;get(&#039;moduleclass_sfx&#039;); ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;?php if ($module-&amp;gt;showtitle != 0) : ?&amp;gt;&lt;br /&gt;
		&amp;lt;dt&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;title; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dt&amp;gt;&lt;br /&gt;
	&amp;lt;?php endif; ?&amp;gt;&lt;br /&gt;
		&amp;lt;dd&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;content; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dd&amp;gt;&lt;br /&gt;
	&amp;lt;/dl&amp;gt;&lt;br /&gt;
	&amp;lt;?php&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We will be calling the style &amp;quot;dlist&amp;quot;, so the name of the function needs to be modChrome_dlist.&lt;br /&gt;
&lt;br /&gt;
The function must take the three arguments as shown for the module object, the module parameters, and lastly the $attribs is an array of all the attributes in the jdoc XML tag.&lt;br /&gt;
&lt;br /&gt;
There are three main properties in the module object to be concerned with:&lt;br /&gt;
&lt;br /&gt;
* showtitle tells you whether to show the title of the module of not&lt;br /&gt;
* title is the title of the module&lt;br /&gt;
* content is the output of the module (from its layout)&lt;br /&gt;
&lt;br /&gt;
This is a very simple case and you can of course design more complex styles, possibly using custom atrributes in the XML tag.&lt;br /&gt;
== Pagination Links Overrides ==&lt;br /&gt;
&lt;br /&gt;
The final override we will look at is the pagination override.  This override can control the display of items-per-page and the pagination links that are used with lists of information, as shown in the following screenshot.&lt;br /&gt;
&lt;br /&gt;
[[Image:Article_list_pagination.png|Typical Joomla! page showing a paginated list.]]&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template provides a well commented example for this override.  The file is found here:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
When the pagination list is required, &amp;quot;Joomla!&amp;quot; will look for this file in the default templates.  If it is found it will be loaded and the display functions it contains will be used.&lt;br /&gt;
&lt;br /&gt;
There are four functions that can be used:&lt;br /&gt;
&lt;br /&gt;
pagination_list_footer&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the select list for the number of items to display per page.&lt;br /&gt;
&lt;br /&gt;
pagination_list_render&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the list of page number links as well at the Start, End, Previous and Next links.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the links to other page numbers other than the &amp;quot;current&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the current page number, usually not hyperlinked.&lt;br /&gt;
&lt;br /&gt;
== Cheat Sheet ==&lt;br /&gt;
&lt;br /&gt;
Using the rhuk_milkyway template as an example, here is a brief summary of the priniciples we&#039;ve looked at.&lt;br /&gt;
=== Customise the Component Output ===&lt;br /&gt;
&lt;br /&gt;
To override a component layout (for example the default layout in the article view), copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about component output.&lt;br /&gt;
=== Customise the Module Output ===&lt;br /&gt;
&lt;br /&gt;
To override a module layout (for example the Latest News module using the rhuk_milkyway template), copy:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about module output.&lt;br /&gt;
=== Add New Module Styles ===&lt;br /&gt;
&lt;br /&gt;
To add new module styles (chrome), add them to the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
Read more about module styles.&lt;br /&gt;
=== Customise the Pagination Links ===&lt;br /&gt;
&lt;br /&gt;
To customise the way the items-per-page selector and pagination links display, edit the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
Read more about [[#Pagination Links Overrides|pagination]].&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.5, through the use of an MVC paradigm has greatly improved the flexibility that is afforded to Web site designers.  By way of a few simple principles, like copying certain files to certain places in your template, the designer is able to override almost all of the output generated by &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If you have any questions relating to output overrides please let us know so that we can improve this tutorial.&lt;br /&gt;
&lt;br /&gt;
If you have translated this article into another language, please let us know.&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8978</id>
		<title>Understanding Output Overrides</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8978"/>
		<updated>2008-07-05T14:22:40Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Pagination Links Overrides */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Understanding Output Overrides in &amp;quot;Joomla!&amp;quot; 1.5 =&lt;br /&gt;
Written by Andrew Eddie&lt;br /&gt;
&lt;br /&gt;
This was Developer Blog post by Andrew, initially copied to the wiki with minor edits by Alan Langford. This is still a work in progress.&lt;br /&gt;
== Introduction ==&lt;br /&gt;
There are many competing requirements for web designers ranging from accessibility to legislative to personal preferences.  Rather than trying to over-parameterise views, or trying to aim for some sort of line of best fit, or worse, sticking its head in the sand, &amp;quot;Joomla!&amp;quot; has added the potential for the designer to take over control of virtually all of the output that is generated.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; has been criticized by some for not giving due attention to accessibility or being archaic in their approach to web standards. However with 1.5, the responsibility, but more importantly the power is back in the designer&#039;s hands.&lt;br /&gt;
&lt;br /&gt;
In addition, except for files that are provided in the &amp;quot;Joomla!&amp;quot; distribution itself, these methods for customisation eliminate the need for designers and developers to &amp;quot;hack&amp;quot; core files that could change when the site is updated to a new version.  Because they are contained within the template, they can be deployed to the Web site without having to worry about changes being accidentally overwritten when your System Administrator upgrades the site.&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to introduce the how fours areas of the output of &amp;quot;Joomla!&amp;quot; are able to be customised by the template designer.&lt;br /&gt;
&lt;br /&gt;
Not interested in all the theory?  Jump straight to the cheat sheet.&lt;br /&gt;
== MVC 101 ==&lt;br /&gt;
MVC can be a scary acronym.  It stands for Model-View-Controller and the concepts behind MVC are responsible for the extra flexibility that is now afforded to the designer.  While parts of the theory can be rather involved and complicated, the only part that the designer need worry about is the V for View.  This is the part that is concerned with output.&lt;br /&gt;
&lt;br /&gt;
Different extensions display output in different ways.&lt;br /&gt;
&lt;br /&gt;
Components, as you would already know, are fairly complex and have the ability to display different information in different ways.  For example, the Articles Component (com_content) is able to display a single article, or articles in a category, or categories in a section.  Each of the ways of representing the different types of data (an article, or a category, or a section) is called a &amp;quot;view&amp;quot; (this comes from our MVC terminology).  Most components will have many views.  However, the view doesn&#039;t actually display the output.  This is left up to what we call a &amp;quot;layout&amp;quot; and it is possible for a view to have a variety of layouts.&lt;br /&gt;
&lt;br /&gt;
The main thing to remember here is that components can have multiple views, and each view can have one or more layouts.  Each view assembles a fixed set of information, but each layout can display that information in different ways.  For example, the Category view in the Articles component assembles a number of articles.  These articles could be displayed in a list or in a table (and probably other ways as well).  So this view may have a &amp;quot;list&amp;quot; layout and a &amp;quot;table&amp;quot; layout to choose from.&lt;br /&gt;
&lt;br /&gt;
Modules, on the other hand, are very simple.  They generally display one thing one way.  Modules don&#039;t really have views but they do support a layout.  Some developers might even support a choice of layout through module parameters.&lt;br /&gt;
=== Template versus Layout ===&lt;br /&gt;
&lt;br /&gt;
It is very important to distinguish between the role of template and the role of layouts.  The template sets up a structural framework for the page of the Web site.  Within this framework are positions for modules and a component to display.  What actually gets displayed is governed by the module layout, or the combination of view and layout in the case of the component.&lt;br /&gt;
&lt;br /&gt;
The following image shows the structural layout of a typical &amp;quot;Joomla!&amp;quot; template (rhuk_milkyway, the default for 1.5).  The module positions are displayed by adding tp=1 to the URL (eg, index.php?tp=1).  You can clearly see where the module output is contained within the overall template, as well as the main component output starting in the lower-centre region.  However, what is actually output in those regions, is controlled by the layouts.&lt;br /&gt;
&lt;br /&gt;
[[Image:FrontpageTemplatePositions.png|Typical Joomla! screenshot with template positions shown.]]&lt;br /&gt;
&lt;br /&gt;
=== Ancillary Customisation ===&lt;br /&gt;
&lt;br /&gt;
While not strictly related to the MVC, there are two other important areas to consider when looking at customising the output of &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In addition to layouts, modules have what we call &amp;quot;chrome&amp;quot;.  Chrome is the style with which a module is to display.  Most developers, designers and probably some end-users will be familiar with the different built-in styles for modules (raw, xhtml, etc).  It is also possible to define your own chrome styles for modules depending on the designer result.  For example, you could design a chrome to display all the modules in a particular position in a fancy Javascript collapsing blind arrangement.&lt;br /&gt;
&lt;br /&gt;
In the screenshot above, you can just make out the names of some of the built-in module chrome used (rounded, none and xhtml).&lt;br /&gt;
&lt;br /&gt;
The second area has to do with controlling the pagination controls when viewing lists of data.  We will look at that in more detail later.&lt;br /&gt;
== Component Output Types and Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
To understand layout overrides we must first understand the file structure of a component.  While there are many parts to a component, all fulfilling different roles and responsibilities, we want to look just in the /views/ directory.  Here is the partial structure for two of the com_content views:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/components&lt;br /&gt;
  /com_content&lt;br /&gt;
	/views&lt;br /&gt;
	  /articles&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  default.php (this is a layout)&lt;br /&gt;
		  form.php	(this is a layout)&lt;br /&gt;
		view.html.php (this is the view that outputs the HTML)&lt;br /&gt;
		view.pdf.php  (this is the view that outputs the PDF)&lt;br /&gt;
	  /category&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  blog.php	   (layout)&lt;br /&gt;
		  blog_items.php (a sub-layout&lt;br /&gt;
		  default.php	(layout)&lt;br /&gt;
		view.html.php	(HTML view)&lt;br /&gt;
		view.feed.php	(RSS feed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
So what you see here is that under the /views/ directory, each view is placed in a directory of its own.  The content component actually has three other views not shown: archive, frontpage and section.&lt;br /&gt;
=== Output Types ===&lt;br /&gt;
Under the /articles/ directory we have a number of files.  There is almost always a file called view.html.php.  This is what we call the view file, but there can be more than one depending on the type of output to produce.  It has a specific naming convention, view.output_type.php, where the output type can be html, feed, pdf, raw or error (for more information see JDocument in the API reference and look in the directory /libraries/joomla/document/).  What this means is when we want html output for this particular view, the view.html.php file is used.  When we want the RSS output, the view.feed.php file is used.&lt;br /&gt;
&lt;br /&gt;
The affect of these different output types is most apparent when the Global Configuration setting for Search Engine Friendly URLs is set to Yes, Use Apache mod_rewrite is set to Yes, and Add suffix to URLs is also set to Yes.  When this is done, the site URLs will look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://domain/sports.html&lt;br /&gt;
http://domain/sports.feed&lt;br /&gt;
http://domain/sports/rowing.html&lt;br /&gt;
http://domain/sports/rowing.pdf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The exact URL will vary depending on how you set up your site but the point here is to show that sports.html will use the category view&#039;s view.html.php file to, and that sports.feed will display the RSS feed for the category using view.feed.php.  It should be noted that you cannot currently customise feed or PDF output types.  However, you can customise the html output type and this is where layouts come into play.&lt;br /&gt;
&lt;br /&gt;
=== Layouts ===&lt;br /&gt;
Under the view directory there is a /tmpl/ directory in which the layout files reside.  Each PHP file in this directory represents a layout.  For example, article/tmpl/default.php is the default layout for an article whereas article/tmpl/form.php is the edit form for an article; category/tmpl/default.php is the default layout for a category whereas category/tmpl/blog.php displays the list of article differently.&lt;br /&gt;
&lt;br /&gt;
The relationship between component views and layout is most plainly seen when adding a new menu item.  The next screenshot represents the typical display of the New Menu Item page.  Having clicked on Articles (which represents com_content), the tree expands to show the list of views and each layout within the view.&lt;br /&gt;
&lt;br /&gt;
[[Image:Menu_item_type_articles.png|Screenshot of creating a new menu item fro an article.]]&lt;br /&gt;
&lt;br /&gt;
You will notice that while there are extra files in some of the /tmpl/ directories (like pagebreak.php in the article view), they are missing from the list.  This is due to instructions in the XML file for the layout (for example, pagebreak.xml) to hide the layout (or even the view) from the menu item list.  However, this is another broad topic which will be covered in another tutorial.&lt;br /&gt;
&lt;br /&gt;
Armed with all that knowledge of how all the parts relate to each other, we are now ready to actually create our layout overrides.&lt;br /&gt;
&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
Layout overrides only work within the active template and are located under the /html/ directory in the template.  For example, the overrides for rhuk_milkyway are located under /templates/rhuk_milkyway/html/, for the JA Purity template under /templates/ja_purity/html/ and for Beez under /templates/beez/html/.&lt;br /&gt;
&lt;br /&gt;
It is important to understand that if you create overrides in one template, they will not be available in other templates.  For example, rhuk_milkyway has no component layout overrides at all.  When you use this template you are seeing the raw output from all components.  When you use the Beez template, almost every piece of component output is being controlled by the layout overrides in the template.  JA Purity is in between having overrides for some components and only some views of those components.&lt;br /&gt;
&lt;br /&gt;
The layout overrides must be placed in particular way.  Using Beez as an example you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /com_content	(this directory matches the component directory name)&lt;br /&gt;
		/articles	 (this directory matches the view directory name)&lt;br /&gt;
		  default.php (this file matches the layout file name)&lt;br /&gt;
		  form.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure for component overrides is quite simple: /html/com_component_name/view_name/layout_file_name.php.  Let&#039;s look at a few examples.&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any components.  If we want to override the default layout for an article, first we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the appropriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
If we wanted to override the blog layout in the category view, we would copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog.php&lt;br /&gt;
&lt;br /&gt;
Once the files are copied, you are free to customise these files as much or as little as required or desired.  You do not have to honour parameter settings if you don&#039;t want to.&lt;br /&gt;
=== Overriding Sub-Layouts ===&lt;br /&gt;
&lt;br /&gt;
In some views you will see that some of the layouts have a group of files that start with the same name.  The category view has an example of this.  The blog layout actually has three parts: the main layout file blog.php and two sub-layout files, blog_item.php and blog_links.php.  You can see where these sub-layouts are loaded in the blog.php file using the loadTemplate method, for example:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;item&#039;);&lt;br /&gt;
// or&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;links&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
When loading sub-layouts, the view already knows what layout you are in, so you don&#039;t have to provide the prefix (that is, you load just &#039;item&#039;, not &#039;blog_item&#039;).&lt;br /&gt;
&lt;br /&gt;
What is important to note here is that it is possible to override just a sub-layout without copying the whole set of files.  For example, if you were happy with the &amp;quot;Joomla!&amp;quot; default output for the blog layout, but just wanted to customise the item sub-layout, you could just copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog_item.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog_item.php&lt;br /&gt;
&lt;br /&gt;
When &amp;quot;Joomla!&amp;quot; is parsing the view, it will automatically know to load blog.php from com_content natively and blog_item.php from your template overrides.&lt;br /&gt;
== Module Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
Modules, like components, are set up in a particular directory structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/modules&lt;br /&gt;
  /mod_latest_news&lt;br /&gt;
	/tmpl&lt;br /&gt;
	  default.php	   (the layout)&lt;br /&gt;
	helper.php		  (a helper file containing data logic)&lt;br /&gt;
	mod_latest_news.php (the main module file)&lt;br /&gt;
	mod_latest_news.xml (the installation XML file)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Similar to components, under the main module directory (in the example, mod_latest_news) there is a /tmpl/ directory.  There is usually only one layout file but depending on who wrote the module, and how it is written, there could be more.&lt;br /&gt;
&lt;br /&gt;
As for components, the layout override for a module must be placed in particular way.  Using Beez as an example again, you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /mod_latest_news.php (this directory matches the module directory name)&lt;br /&gt;
		default.php		(this file matches the layout file name)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The structure for module overrides is again quite simple: /html/mod_module_name/layout_file_name.php.&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any modules.  If we want to override the default layout for Latest News module, we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the approriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
You need to take a little care with overriding module layout because there are a number of different ways that modules can or have been designed so you need to treat each one individually.&lt;br /&gt;
== Module Chrome ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.0 had a number of fixed styles that could display a list of modules in a particular position.  These where represented by numbers:&lt;br /&gt;
&lt;br /&gt;
* 0 (the default) displayed modules in a vertical table&lt;br /&gt;
* 1 displayed them in a horizontal table&lt;br /&gt;
* -1 displayed the raw module output&lt;br /&gt;
* -2 displayed the modules in a XHTML compatible format with the title in a H3 tag.&lt;br /&gt;
* -3 displayed modules in a set of nested DIVs that allowed for rounded-corner techniques&lt;br /&gt;
&lt;br /&gt;
It was a great system except for two things:&lt;br /&gt;
&lt;br /&gt;
# Nobody could remember which number was which, and&lt;br /&gt;
# You couldn&#039;t expand on the styles.&lt;br /&gt;
&lt;br /&gt;
Well, in 1.5, the numbers are still recognised, but more commonly the style is represented as a word.  As well as that, the syntax for displaying a module position was changed.  For example, this snippet displays each module in the left position in the xhtml style:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;jdoc:include type=&amp;quot;modules&amp;quot; name=&amp;quot;left&amp;quot; style=&amp;quot;xhtml&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The built-in styles that are now available are:&lt;br /&gt;
&lt;br /&gt;
* table (was 0 and is the default)&lt;br /&gt;
* horz (was 1)&lt;br /&gt;
* none (was -1)&lt;br /&gt;
* xhtml (was -2)&lt;br /&gt;
* rounded (was -3)&lt;br /&gt;
* outline (new - used to preview module positions - see screenshot above)&lt;br /&gt;
&lt;br /&gt;
In the source code, these styles are actually referred to ask &amp;quot;chrome&amp;quot;.  The default chrome can actually be found in the system template provided in the default &amp;quot;Joomla!&amp;quot; install:&lt;br /&gt;
&lt;br /&gt;
/templates/system/html/modules.php&lt;br /&gt;
&lt;br /&gt;
This file is maintained by the project so you should never modify it directly otherwise there is a risk that you will loose your changes if and when you upgrade your &amp;quot;Joomla!&amp;quot; installation.&lt;br /&gt;
&lt;br /&gt;
To create your own chrome, or module styles, all you need to do is create or edit modules.php under the templates /html/ directory (this is the same directory we have been talking about for component and module layout overrides).&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template actually does provide some extra chrome as an example (it provides and new example style called &amp;quot;slider&amp;quot;).  This can be found in the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
To create your own chrome is really easy.  Let&#039;s look at ficticious example that displays the module in a Definition List (a set of DL&#039;s, DT&#039;s and DD&#039;s).&lt;br /&gt;
&lt;br /&gt;
Just add the following function to the /html/modules.php file in your default template directory (create it if it does not exist):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * Module chrome that wraps the module in a definition list&lt;br /&gt;
 */&lt;br /&gt;
function modChrome_dlist($module, &amp;amp;$params, &amp;amp;$attribs)&lt;br /&gt;
{ ?&amp;gt;&lt;br /&gt;
	&amp;lt;dl class=&amp;quot;&amp;lt;?php echo $params-&amp;gt;get(&#039;moduleclass_sfx&#039;); ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;?php if ($module-&amp;gt;showtitle != 0) : ?&amp;gt;&lt;br /&gt;
		&amp;lt;dt&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;title; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dt&amp;gt;&lt;br /&gt;
	&amp;lt;?php endif; ?&amp;gt;&lt;br /&gt;
		&amp;lt;dd&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;content; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dd&amp;gt;&lt;br /&gt;
	&amp;lt;/dl&amp;gt;&lt;br /&gt;
	&amp;lt;?php&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We will be calling the style &amp;quot;dlist&amp;quot;, so the name of the function needs to be modChrome_dlist.&lt;br /&gt;
&lt;br /&gt;
The function must take the three arguments as shown for the module object, the module parameters, and lastly the $attribs is an array of all the attributes in the jdoc XML tag.&lt;br /&gt;
&lt;br /&gt;
There are three main properties in the module object to be concerned with:&lt;br /&gt;
&lt;br /&gt;
* showtitle tells you whether to show the title of the module of not&lt;br /&gt;
* title is the title of the module&lt;br /&gt;
* content is the output of the module (from its layout)&lt;br /&gt;
&lt;br /&gt;
This is a very simple case and you can of course design more complex styles, possibly using custom atrributes in the XML tag.&lt;br /&gt;
== Pagination Links Overrides ==&lt;br /&gt;
&lt;br /&gt;
The final override we will look at is the pagination override.  This override can control the display of items-per-page and the pagination links that are used with lists of information, as shown in the following screenshot.&lt;br /&gt;
&lt;br /&gt;
[[Image:Article_list_pagination.png|Typical Joomla! page showing a paginated list.]]&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template provides a well commented example for this override.  The file is found here:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
When the pagination list is required, &amp;quot;Joomla!&amp;quot; will look for this file in the default templates.  If it is found it will be loaded and the display functions it contains will be used.&lt;br /&gt;
&lt;br /&gt;
There are four functions that can be used:&lt;br /&gt;
&lt;br /&gt;
pagination_list_footer&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the select list for the number of items to display per page.&lt;br /&gt;
&lt;br /&gt;
pagination_list_render&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the list of page number links as well at the Start, End, Previous and Next links.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the links to other page numbers other than the &amp;quot;current&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the current page number, usually not hyperlinked.&lt;br /&gt;
&lt;br /&gt;
== Cheat Sheet ==&lt;br /&gt;
&lt;br /&gt;
Using the rhuk_milkyway template as an example, here is a brief summary of the priniciples we&#039;ve looked at.&lt;br /&gt;
=== Customise the Component Output ===&lt;br /&gt;
&lt;br /&gt;
To override a component layout (for example the default layout in the article view), copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about component output.&lt;br /&gt;
=== Customise the Module Output ===&lt;br /&gt;
&lt;br /&gt;
To override a module layout (for example the Latest News module using the rhuk_milkyway template), copy:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about module output.&lt;br /&gt;
=== Add New Module Styles ===&lt;br /&gt;
&lt;br /&gt;
To add new module styles (chrome), add them to the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
Read more about module styles.&lt;br /&gt;
=== Customise the Pagination Links ===&lt;br /&gt;
&lt;br /&gt;
To customise the way the items-per-page selector and pagination links display, edit the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
Read more about pagination.&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.5, through the use of an MVC paradigm has greatly improved the flexibility that is afforded to Web site designers.  By way of a few simple principles, like copying certain files to certain places in your template, the designer is able to override almost all of the output generated by &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If you have any questions relating to output overrides please let us know so that we can improve this tutorial.&lt;br /&gt;
&lt;br /&gt;
If you have translated this article into another language, please let us know.&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=File:Article_list_pagination.png&amp;diff=8977</id>
		<title>File:Article list pagination.png</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=File:Article_list_pagination.png&amp;diff=8977"/>
		<updated>2008-07-05T14:20:24Z</updated>

		<summary type="html">&lt;p&gt;Instance: screenshot: List of articles with pagination elements highlighted.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
screenshot: List of articles with pagination elements highlighted.&lt;br /&gt;
== Licensing ==&lt;br /&gt;
{{JEDL}}&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8976</id>
		<title>Understanding Output Overrides</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8976"/>
		<updated>2008-07-05T14:14:31Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Layouts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Understanding Output Overrides in &amp;quot;Joomla!&amp;quot; 1.5 =&lt;br /&gt;
Written by Andrew Eddie&lt;br /&gt;
&lt;br /&gt;
This was Developer Blog post by Andrew, initially copied to the wiki with minor edits by Alan Langford. This is still a work in progress.&lt;br /&gt;
== Introduction ==&lt;br /&gt;
There are many competing requirements for web designers ranging from accessibility to legislative to personal preferences.  Rather than trying to over-parameterise views, or trying to aim for some sort of line of best fit, or worse, sticking its head in the sand, &amp;quot;Joomla!&amp;quot; has added the potential for the designer to take over control of virtually all of the output that is generated.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; has been criticized by some for not giving due attention to accessibility or being archaic in their approach to web standards. However with 1.5, the responsibility, but more importantly the power is back in the designer&#039;s hands.&lt;br /&gt;
&lt;br /&gt;
In addition, except for files that are provided in the &amp;quot;Joomla!&amp;quot; distribution itself, these methods for customisation eliminate the need for designers and developers to &amp;quot;hack&amp;quot; core files that could change when the site is updated to a new version.  Because they are contained within the template, they can be deployed to the Web site without having to worry about changes being accidentally overwritten when your System Administrator upgrades the site.&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to introduce the how fours areas of the output of &amp;quot;Joomla!&amp;quot; are able to be customised by the template designer.&lt;br /&gt;
&lt;br /&gt;
Not interested in all the theory?  Jump straight to the cheat sheet.&lt;br /&gt;
== MVC 101 ==&lt;br /&gt;
MVC can be a scary acronym.  It stands for Model-View-Controller and the concepts behind MVC are responsible for the extra flexibility that is now afforded to the designer.  While parts of the theory can be rather involved and complicated, the only part that the designer need worry about is the V for View.  This is the part that is concerned with output.&lt;br /&gt;
&lt;br /&gt;
Different extensions display output in different ways.&lt;br /&gt;
&lt;br /&gt;
Components, as you would already know, are fairly complex and have the ability to display different information in different ways.  For example, the Articles Component (com_content) is able to display a single article, or articles in a category, or categories in a section.  Each of the ways of representing the different types of data (an article, or a category, or a section) is called a &amp;quot;view&amp;quot; (this comes from our MVC terminology).  Most components will have many views.  However, the view doesn&#039;t actually display the output.  This is left up to what we call a &amp;quot;layout&amp;quot; and it is possible for a view to have a variety of layouts.&lt;br /&gt;
&lt;br /&gt;
The main thing to remember here is that components can have multiple views, and each view can have one or more layouts.  Each view assembles a fixed set of information, but each layout can display that information in different ways.  For example, the Category view in the Articles component assembles a number of articles.  These articles could be displayed in a list or in a table (and probably other ways as well).  So this view may have a &amp;quot;list&amp;quot; layout and a &amp;quot;table&amp;quot; layout to choose from.&lt;br /&gt;
&lt;br /&gt;
Modules, on the other hand, are very simple.  They generally display one thing one way.  Modules don&#039;t really have views but they do support a layout.  Some developers might even support a choice of layout through module parameters.&lt;br /&gt;
=== Template versus Layout ===&lt;br /&gt;
&lt;br /&gt;
It is very important to distinguish between the role of template and the role of layouts.  The template sets up a structural framework for the page of the Web site.  Within this framework are positions for modules and a component to display.  What actually gets displayed is governed by the module layout, or the combination of view and layout in the case of the component.&lt;br /&gt;
&lt;br /&gt;
The following image shows the structural layout of a typical &amp;quot;Joomla!&amp;quot; template (rhuk_milkyway, the default for 1.5).  The module positions are displayed by adding tp=1 to the URL (eg, index.php?tp=1).  You can clearly see where the module output is contained within the overall template, as well as the main component output starting in the lower-centre region.  However, what is actually output in those regions, is controlled by the layouts.&lt;br /&gt;
&lt;br /&gt;
[[Image:FrontpageTemplatePositions.png|Typical Joomla! screenshot with template positions shown.]]&lt;br /&gt;
&lt;br /&gt;
=== Ancillary Customisation ===&lt;br /&gt;
&lt;br /&gt;
While not strictly related to the MVC, there are two other important areas to consider when looking at customising the output of &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In addition to layouts, modules have what we call &amp;quot;chrome&amp;quot;.  Chrome is the style with which a module is to display.  Most developers, designers and probably some end-users will be familiar with the different built-in styles for modules (raw, xhtml, etc).  It is also possible to define your own chrome styles for modules depending on the designer result.  For example, you could design a chrome to display all the modules in a particular position in a fancy Javascript collapsing blind arrangement.&lt;br /&gt;
&lt;br /&gt;
In the screenshot above, you can just make out the names of some of the built-in module chrome used (rounded, none and xhtml).&lt;br /&gt;
&lt;br /&gt;
The second area has to do with controlling the pagination controls when viewing lists of data.  We will look at that in more detail later.&lt;br /&gt;
== Component Output Types and Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
To understand layout overrides we must first understand the file structure of a component.  While there are many parts to a component, all fulfilling different roles and responsibilities, we want to look just in the /views/ directory.  Here is the partial structure for two of the com_content views:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/components&lt;br /&gt;
  /com_content&lt;br /&gt;
	/views&lt;br /&gt;
	  /articles&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  default.php (this is a layout)&lt;br /&gt;
		  form.php	(this is a layout)&lt;br /&gt;
		view.html.php (this is the view that outputs the HTML)&lt;br /&gt;
		view.pdf.php  (this is the view that outputs the PDF)&lt;br /&gt;
	  /category&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  blog.php	   (layout)&lt;br /&gt;
		  blog_items.php (a sub-layout&lt;br /&gt;
		  default.php	(layout)&lt;br /&gt;
		view.html.php	(HTML view)&lt;br /&gt;
		view.feed.php	(RSS feed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
So what you see here is that under the /views/ directory, each view is placed in a directory of its own.  The content component actually has three other views not shown: archive, frontpage and section.&lt;br /&gt;
=== Output Types ===&lt;br /&gt;
Under the /articles/ directory we have a number of files.  There is almost always a file called view.html.php.  This is what we call the view file, but there can be more than one depending on the type of output to produce.  It has a specific naming convention, view.output_type.php, where the output type can be html, feed, pdf, raw or error (for more information see JDocument in the API reference and look in the directory /libraries/joomla/document/).  What this means is when we want html output for this particular view, the view.html.php file is used.  When we want the RSS output, the view.feed.php file is used.&lt;br /&gt;
&lt;br /&gt;
The affect of these different output types is most apparent when the Global Configuration setting for Search Engine Friendly URLs is set to Yes, Use Apache mod_rewrite is set to Yes, and Add suffix to URLs is also set to Yes.  When this is done, the site URLs will look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://domain/sports.html&lt;br /&gt;
http://domain/sports.feed&lt;br /&gt;
http://domain/sports/rowing.html&lt;br /&gt;
http://domain/sports/rowing.pdf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The exact URL will vary depending on how you set up your site but the point here is to show that sports.html will use the category view&#039;s view.html.php file to, and that sports.feed will display the RSS feed for the category using view.feed.php.  It should be noted that you cannot currently customise feed or PDF output types.  However, you can customise the html output type and this is where layouts come into play.&lt;br /&gt;
&lt;br /&gt;
=== Layouts ===&lt;br /&gt;
Under the view directory there is a /tmpl/ directory in which the layout files reside.  Each PHP file in this directory represents a layout.  For example, article/tmpl/default.php is the default layout for an article whereas article/tmpl/form.php is the edit form for an article; category/tmpl/default.php is the default layout for a category whereas category/tmpl/blog.php displays the list of article differently.&lt;br /&gt;
&lt;br /&gt;
The relationship between component views and layout is most plainly seen when adding a new menu item.  The next screenshot represents the typical display of the New Menu Item page.  Having clicked on Articles (which represents com_content), the tree expands to show the list of views and each layout within the view.&lt;br /&gt;
&lt;br /&gt;
[[Image:Menu_item_type_articles.png|Screenshot of creating a new menu item fro an article.]]&lt;br /&gt;
&lt;br /&gt;
You will notice that while there are extra files in some of the /tmpl/ directories (like pagebreak.php in the article view), they are missing from the list.  This is due to instructions in the XML file for the layout (for example, pagebreak.xml) to hide the layout (or even the view) from the menu item list.  However, this is another broad topic which will be covered in another tutorial.&lt;br /&gt;
&lt;br /&gt;
Armed with all that knowledge of how all the parts relate to each other, we are now ready to actually create our layout overrides.&lt;br /&gt;
&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
Layout overrides only work within the active template and are located under the /html/ directory in the template.  For example, the overrides for rhuk_milkyway are located under /templates/rhuk_milkyway/html/, for the JA Purity template under /templates/ja_purity/html/ and for Beez under /templates/beez/html/.&lt;br /&gt;
&lt;br /&gt;
It is important to understand that if you create overrides in one template, they will not be available in other templates.  For example, rhuk_milkyway has no component layout overrides at all.  When you use this template you are seeing the raw output from all components.  When you use the Beez template, almost every piece of component output is being controlled by the layout overrides in the template.  JA Purity is in between having overrides for some components and only some views of those components.&lt;br /&gt;
&lt;br /&gt;
The layout overrides must be placed in particular way.  Using Beez as an example you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /com_content	(this directory matches the component directory name)&lt;br /&gt;
		/articles	 (this directory matches the view directory name)&lt;br /&gt;
		  default.php (this file matches the layout file name)&lt;br /&gt;
		  form.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure for component overrides is quite simple: /html/com_component_name/view_name/layout_file_name.php.  Let&#039;s look at a few examples.&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any components.  If we want to override the default layout for an article, first we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the appropriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
If we wanted to override the blog layout in the category view, we would copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog.php&lt;br /&gt;
&lt;br /&gt;
Once the files are copied, you are free to customise these files as much or as little as required or desired.  You do not have to honour parameter settings if you don&#039;t want to.&lt;br /&gt;
=== Overriding Sub-Layouts ===&lt;br /&gt;
&lt;br /&gt;
In some views you will see that some of the layouts have a group of files that start with the same name.  The category view has an example of this.  The blog layout actually has three parts: the main layout file blog.php and two sub-layout files, blog_item.php and blog_links.php.  You can see where these sub-layouts are loaded in the blog.php file using the loadTemplate method, for example:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;item&#039;);&lt;br /&gt;
// or&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;links&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
When loading sub-layouts, the view already knows what layout you are in, so you don&#039;t have to provide the prefix (that is, you load just &#039;item&#039;, not &#039;blog_item&#039;).&lt;br /&gt;
&lt;br /&gt;
What is important to note here is that it is possible to override just a sub-layout without copying the whole set of files.  For example, if you were happy with the &amp;quot;Joomla!&amp;quot; default output for the blog layout, but just wanted to customise the item sub-layout, you could just copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog_item.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog_item.php&lt;br /&gt;
&lt;br /&gt;
When &amp;quot;Joomla!&amp;quot; is parsing the view, it will automatically know to load blog.php from com_content natively and blog_item.php from your template overrides.&lt;br /&gt;
== Module Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
Modules, like components, are set up in a particular directory structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/modules&lt;br /&gt;
  /mod_latest_news&lt;br /&gt;
	/tmpl&lt;br /&gt;
	  default.php	   (the layout)&lt;br /&gt;
	helper.php		  (a helper file containing data logic)&lt;br /&gt;
	mod_latest_news.php (the main module file)&lt;br /&gt;
	mod_latest_news.xml (the installation XML file)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Similar to components, under the main module directory (in the example, mod_latest_news) there is a /tmpl/ directory.  There is usually only one layout file but depending on who wrote the module, and how it is written, there could be more.&lt;br /&gt;
&lt;br /&gt;
As for components, the layout override for a module must be placed in particular way.  Using Beez as an example again, you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /mod_latest_news.php (this directory matches the module directory name)&lt;br /&gt;
		default.php		(this file matches the layout file name)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The structure for module overrides is again quite simple: /html/mod_module_name/layout_file_name.php.&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any modules.  If we want to override the default layout for Latest News module, we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the approriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
You need to take a little care with overriding module layout because there are a number of different ways that modules can or have been designed so you need to treat each one individually.&lt;br /&gt;
== Module Chrome ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.0 had a number of fixed styles that could display a list of modules in a particular position.  These where represented by numbers:&lt;br /&gt;
&lt;br /&gt;
* 0 (the default) displayed modules in a vertical table&lt;br /&gt;
* 1 displayed them in a horizontal table&lt;br /&gt;
* -1 displayed the raw module output&lt;br /&gt;
* -2 displayed the modules in a XHTML compatible format with the title in a H3 tag.&lt;br /&gt;
* -3 displayed modules in a set of nested DIVs that allowed for rounded-corner techniques&lt;br /&gt;
&lt;br /&gt;
It was a great system except for two things:&lt;br /&gt;
&lt;br /&gt;
# Nobody could remember which number was which, and&lt;br /&gt;
# You couldn&#039;t expand on the styles.&lt;br /&gt;
&lt;br /&gt;
Well, in 1.5, the numbers are still recognised, but more commonly the style is represented as a word.  As well as that, the syntax for displaying a module position was changed.  For example, this snippet displays each module in the left position in the xhtml style:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;jdoc:include type=&amp;quot;modules&amp;quot; name=&amp;quot;left&amp;quot; style=&amp;quot;xhtml&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The built-in styles that are now available are:&lt;br /&gt;
&lt;br /&gt;
* table (was 0 and is the default)&lt;br /&gt;
* horz (was 1)&lt;br /&gt;
* none (was -1)&lt;br /&gt;
* xhtml (was -2)&lt;br /&gt;
* rounded (was -3)&lt;br /&gt;
* outline (new - used to preview module positions - see screenshot above)&lt;br /&gt;
&lt;br /&gt;
In the source code, these styles are actually referred to ask &amp;quot;chrome&amp;quot;.  The default chrome can actually be found in the system template provided in the default &amp;quot;Joomla!&amp;quot; install:&lt;br /&gt;
&lt;br /&gt;
/templates/system/html/modules.php&lt;br /&gt;
&lt;br /&gt;
This file is maintained by the project so you should never modify it directly otherwise there is a risk that you will loose your changes if and when you upgrade your &amp;quot;Joomla!&amp;quot; installation.&lt;br /&gt;
&lt;br /&gt;
To create your own chrome, or module styles, all you need to do is create or edit modules.php under the templates /html/ directory (this is the same directory we have been talking about for component and module layout overrides).&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template actually does provide some extra chrome as an example (it provides and new example style called &amp;quot;slider&amp;quot;).  This can be found in the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
To create your own chrome is really easy.  Let&#039;s look at ficticious example that displays the module in a Definition List (a set of DL&#039;s, DT&#039;s and DD&#039;s).&lt;br /&gt;
&lt;br /&gt;
Just add the following function to the /html/modules.php file in your default template directory (create it if it does not exist):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * Module chrome that wraps the module in a definition list&lt;br /&gt;
 */&lt;br /&gt;
function modChrome_dlist($module, &amp;amp;$params, &amp;amp;$attribs)&lt;br /&gt;
{ ?&amp;gt;&lt;br /&gt;
	&amp;lt;dl class=&amp;quot;&amp;lt;?php echo $params-&amp;gt;get(&#039;moduleclass_sfx&#039;); ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;?php if ($module-&amp;gt;showtitle != 0) : ?&amp;gt;&lt;br /&gt;
		&amp;lt;dt&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;title; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dt&amp;gt;&lt;br /&gt;
	&amp;lt;?php endif; ?&amp;gt;&lt;br /&gt;
		&amp;lt;dd&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;content; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dd&amp;gt;&lt;br /&gt;
	&amp;lt;/dl&amp;gt;&lt;br /&gt;
	&amp;lt;?php&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We will be calling the style &amp;quot;dlist&amp;quot;, so the name of the function needs to be modChrome_dlist.&lt;br /&gt;
&lt;br /&gt;
The function must take the three arguments as shown for the module object, the module parameters, and lastly the $attribs is an array of all the attributes in the jdoc XML tag.&lt;br /&gt;
&lt;br /&gt;
There are three main properties in the module object to be concerned with:&lt;br /&gt;
&lt;br /&gt;
* showtitle tells you whether to show the title of the module of not&lt;br /&gt;
* title is the title of the module&lt;br /&gt;
* content is the output of the module (from its layout)&lt;br /&gt;
&lt;br /&gt;
This is a very simple case and you can of course design more complex styles, possibly using custom atrributes in the XML tag.&lt;br /&gt;
== Pagination Links Overrides ==&lt;br /&gt;
&lt;br /&gt;
The final override we will look at is the pagination override.  This override can control the display of items-per-page and the pagination links that are used with lists of information, as shown in the following screenshot.&lt;br /&gt;
&lt;br /&gt;
http://developer.joomla.org/images/tutorials/understanding_output/pagination_links.png&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template provides a well commented example for this override.  The file is found here:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
When the pagination list is required, &amp;quot;Joomla!&amp;quot; will look for this file in the default templates.  If it is found it will be loaded and the display functions it contains will be used.&lt;br /&gt;
&lt;br /&gt;
There are four functions that can be used:&lt;br /&gt;
&lt;br /&gt;
pagination_list_footer&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the select list for the number of items to display per page.&lt;br /&gt;
&lt;br /&gt;
pagination_list_render&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the list of page number links as well at the Start, End, Previous and Next links.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the links to other page numbers other than the &amp;quot;current&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the current page number, usually not hyperlinked.&lt;br /&gt;
== Cheat Sheet ==&lt;br /&gt;
&lt;br /&gt;
Using the rhuk_milkyway template as an example, here is a brief summary of the priniciples we&#039;ve looked at.&lt;br /&gt;
=== Customise the Component Output ===&lt;br /&gt;
&lt;br /&gt;
To override a component layout (for example the default layout in the article view), copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about component output.&lt;br /&gt;
=== Customise the Module Output ===&lt;br /&gt;
&lt;br /&gt;
To override a module layout (for example the Latest News module using the rhuk_milkyway template), copy:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about module output.&lt;br /&gt;
=== Add New Module Styles ===&lt;br /&gt;
&lt;br /&gt;
To add new module styles (chrome), add them to the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
Read more about module styles.&lt;br /&gt;
=== Customise the Pagination Links ===&lt;br /&gt;
&lt;br /&gt;
To customise the way the items-per-page selector and pagination links display, edit the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
Read more about pagination.&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.5, through the use of an MVC paradigm has greatly improved the flexibility that is afforded to Web site designers.  By way of a few simple principles, like copying certain files to certain places in your template, the designer is able to override almost all of the output generated by &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If you have any questions relating to output overrides please let us know so that we can improve this tutorial.&lt;br /&gt;
&lt;br /&gt;
If you have translated this article into another language, please let us know.&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8975</id>
		<title>Understanding Output Overrides</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8975"/>
		<updated>2008-07-05T14:09:23Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Template versus Layout */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Understanding Output Overrides in &amp;quot;Joomla!&amp;quot; 1.5 =&lt;br /&gt;
Written by Andrew Eddie&lt;br /&gt;
&lt;br /&gt;
This was Developer Blog post by Andrew, initially copied to the wiki with minor edits by Alan Langford. This is still a work in progress.&lt;br /&gt;
== Introduction ==&lt;br /&gt;
There are many competing requirements for web designers ranging from accessibility to legislative to personal preferences.  Rather than trying to over-parameterise views, or trying to aim for some sort of line of best fit, or worse, sticking its head in the sand, &amp;quot;Joomla!&amp;quot; has added the potential for the designer to take over control of virtually all of the output that is generated.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; has been criticized by some for not giving due attention to accessibility or being archaic in their approach to web standards. However with 1.5, the responsibility, but more importantly the power is back in the designer&#039;s hands.&lt;br /&gt;
&lt;br /&gt;
In addition, except for files that are provided in the &amp;quot;Joomla!&amp;quot; distribution itself, these methods for customisation eliminate the need for designers and developers to &amp;quot;hack&amp;quot; core files that could change when the site is updated to a new version.  Because they are contained within the template, they can be deployed to the Web site without having to worry about changes being accidentally overwritten when your System Administrator upgrades the site.&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to introduce the how fours areas of the output of &amp;quot;Joomla!&amp;quot; are able to be customised by the template designer.&lt;br /&gt;
&lt;br /&gt;
Not interested in all the theory?  Jump straight to the cheat sheet.&lt;br /&gt;
== MVC 101 ==&lt;br /&gt;
MVC can be a scary acronym.  It stands for Model-View-Controller and the concepts behind MVC are responsible for the extra flexibility that is now afforded to the designer.  While parts of the theory can be rather involved and complicated, the only part that the designer need worry about is the V for View.  This is the part that is concerned with output.&lt;br /&gt;
&lt;br /&gt;
Different extensions display output in different ways.&lt;br /&gt;
&lt;br /&gt;
Components, as you would already know, are fairly complex and have the ability to display different information in different ways.  For example, the Articles Component (com_content) is able to display a single article, or articles in a category, or categories in a section.  Each of the ways of representing the different types of data (an article, or a category, or a section) is called a &amp;quot;view&amp;quot; (this comes from our MVC terminology).  Most components will have many views.  However, the view doesn&#039;t actually display the output.  This is left up to what we call a &amp;quot;layout&amp;quot; and it is possible for a view to have a variety of layouts.&lt;br /&gt;
&lt;br /&gt;
The main thing to remember here is that components can have multiple views, and each view can have one or more layouts.  Each view assembles a fixed set of information, but each layout can display that information in different ways.  For example, the Category view in the Articles component assembles a number of articles.  These articles could be displayed in a list or in a table (and probably other ways as well).  So this view may have a &amp;quot;list&amp;quot; layout and a &amp;quot;table&amp;quot; layout to choose from.&lt;br /&gt;
&lt;br /&gt;
Modules, on the other hand, are very simple.  They generally display one thing one way.  Modules don&#039;t really have views but they do support a layout.  Some developers might even support a choice of layout through module parameters.&lt;br /&gt;
=== Template versus Layout ===&lt;br /&gt;
&lt;br /&gt;
It is very important to distinguish between the role of template and the role of layouts.  The template sets up a structural framework for the page of the Web site.  Within this framework are positions for modules and a component to display.  What actually gets displayed is governed by the module layout, or the combination of view and layout in the case of the component.&lt;br /&gt;
&lt;br /&gt;
The following image shows the structural layout of a typical &amp;quot;Joomla!&amp;quot; template (rhuk_milkyway, the default for 1.5).  The module positions are displayed by adding tp=1 to the URL (eg, index.php?tp=1).  You can clearly see where the module output is contained within the overall template, as well as the main component output starting in the lower-centre region.  However, what is actually output in those regions, is controlled by the layouts.&lt;br /&gt;
&lt;br /&gt;
[[Image:FrontpageTemplatePositions.png|Typical Joomla! screenshot with template positions shown.]]&lt;br /&gt;
&lt;br /&gt;
=== Ancillary Customisation ===&lt;br /&gt;
&lt;br /&gt;
While not strictly related to the MVC, there are two other important areas to consider when looking at customising the output of &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In addition to layouts, modules have what we call &amp;quot;chrome&amp;quot;.  Chrome is the style with which a module is to display.  Most developers, designers and probably some end-users will be familiar with the different built-in styles for modules (raw, xhtml, etc).  It is also possible to define your own chrome styles for modules depending on the designer result.  For example, you could design a chrome to display all the modules in a particular position in a fancy Javascript collapsing blind arrangement.&lt;br /&gt;
&lt;br /&gt;
In the screenshot above, you can just make out the names of some of the built-in module chrome used (rounded, none and xhtml).&lt;br /&gt;
&lt;br /&gt;
The second area has to do with controlling the pagination controls when viewing lists of data.  We will look at that in more detail later.&lt;br /&gt;
== Component Output Types and Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
To understand layout overrides we must first understand the file structure of a component.  While there are many parts to a component, all fulfilling different roles and responsibilities, we want to look just in the /views/ directory.  Here is the partial structure for two of the com_content views:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/components&lt;br /&gt;
  /com_content&lt;br /&gt;
	/views&lt;br /&gt;
	  /articles&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  default.php (this is a layout)&lt;br /&gt;
		  form.php	(this is a layout)&lt;br /&gt;
		view.html.php (this is the view that outputs the HTML)&lt;br /&gt;
		view.pdf.php  (this is the view that outputs the PDF)&lt;br /&gt;
	  /category&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  blog.php	   (layout)&lt;br /&gt;
		  blog_items.php (a sub-layout&lt;br /&gt;
		  default.php	(layout)&lt;br /&gt;
		view.html.php	(HTML view)&lt;br /&gt;
		view.feed.php	(RSS feed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
So what you see here is that under the /views/ directory, each view is placed in a directory of its own.  The content component actually has three other views not shown: archive, frontpage and section.&lt;br /&gt;
=== Output Types ===&lt;br /&gt;
Under the /articles/ directory we have a number of files.  There is almost always a file called view.html.php.  This is what we call the view file, but there can be more than one depending on the type of output to produce.  It has a specific naming convention, view.output_type.php, where the output type can be html, feed, pdf, raw or error (for more information see JDocument in the API reference and look in the directory /libraries/joomla/document/).  What this means is when we want html output for this particular view, the view.html.php file is used.  When we want the RSS output, the view.feed.php file is used.&lt;br /&gt;
&lt;br /&gt;
The affect of these different output types is most apparent when the Global Configuration setting for Search Engine Friendly URLs is set to Yes, Use Apache mod_rewrite is set to Yes, and Add suffix to URLs is also set to Yes.  When this is done, the site URLs will look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://domain/sports.html&lt;br /&gt;
http://domain/sports.feed&lt;br /&gt;
http://domain/sports/rowing.html&lt;br /&gt;
http://domain/sports/rowing.pdf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The exact URL will vary depending on how you set up your site but the point here is to show that sports.html will use the category view&#039;s view.html.php file to, and that sports.feed will display the RSS feed for the category using view.feed.php.  It should be noted that you cannot currently customise feed or PDF output types.  However, you can customise the html output type and this is where layouts come into play.&lt;br /&gt;
&lt;br /&gt;
=== Layouts ===&lt;br /&gt;
Under the view directory there is a /tmpl/ directory in which the layout files reside.  Each PHP file in this directory represents a layout.  For example, article/tmpl/default.php is the default layout for an article whereas article/tmpl/form.php is the edit form for an article; category/tmpl/default.php is the default layout for a category whereas category/tmpl/blog.php displays the list of article differently.&lt;br /&gt;
&lt;br /&gt;
The relationship between component views and layout is most plainly seen when adding a new menu item.  The next screenshot represents the typical display of the New Menu Item page.  Having clicked on Articles (which represents com_content), the tree expands to show the list of views and each layout within the view.&lt;br /&gt;
&lt;br /&gt;
http://developer.joomla.org/images/tutorials/understanding_output/menu_item_new.png&lt;br /&gt;
&lt;br /&gt;
You will notice that while there are extra files in some of the /tmpl/ directories (like pagebreak.php in the article view), they are missing from the list.  This is due to instructions in the XML file for the layout (for example, pagebreak.xml) to hide the layout (or even the view) from the menu item list.  However, this is another broad topic which will be covered in another tutorial.&lt;br /&gt;
&lt;br /&gt;
Armed with all that knowledge of how all the parts relate to each other, we are now ready to actually create our layout overrides.&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
Layout overrides only work within the active template and are located under the /html/ directory in the template.  For example, the overrides for rhuk_milkyway are located under /templates/rhuk_milkyway/html/, for the JA Purity template under /templates/ja_purity/html/ and for Beez under /templates/beez/html/.&lt;br /&gt;
&lt;br /&gt;
It is important to understand that if you create overrides in one template, they will not be available in other templates.  For example, rhuk_milkyway has no component layout overrides at all.  When you use this template you are seeing the raw output from all components.  When you use the Beez template, almost every piece of component output is being controlled by the layout overrides in the template.  JA Purity is in between having overrides for some components and only some views of those components.&lt;br /&gt;
&lt;br /&gt;
The layout overrides must be placed in particular way.  Using Beez as an example you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /com_content	(this directory matches the component directory name)&lt;br /&gt;
		/articles	 (this directory matches the view directory name)&lt;br /&gt;
		  default.php (this file matches the layout file name)&lt;br /&gt;
		  form.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure for component overrides is quite simple: /html/com_component_name/view_name/layout_file_name.php.  Let&#039;s look at a few examples.&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any components.  If we want to override the default layout for an article, first we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the appropriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
If we wanted to override the blog layout in the category view, we would copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog.php&lt;br /&gt;
&lt;br /&gt;
Once the files are copied, you are free to customise these files as much or as little as required or desired.  You do not have to honour parameter settings if you don&#039;t want to.&lt;br /&gt;
=== Overriding Sub-Layouts ===&lt;br /&gt;
&lt;br /&gt;
In some views you will see that some of the layouts have a group of files that start with the same name.  The category view has an example of this.  The blog layout actually has three parts: the main layout file blog.php and two sub-layout files, blog_item.php and blog_links.php.  You can see where these sub-layouts are loaded in the blog.php file using the loadTemplate method, for example:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;item&#039;);&lt;br /&gt;
// or&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;links&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
When loading sub-layouts, the view already knows what layout you are in, so you don&#039;t have to provide the prefix (that is, you load just &#039;item&#039;, not &#039;blog_item&#039;).&lt;br /&gt;
&lt;br /&gt;
What is important to note here is that it is possible to override just a sub-layout without copying the whole set of files.  For example, if you were happy with the &amp;quot;Joomla!&amp;quot; default output for the blog layout, but just wanted to customise the item sub-layout, you could just copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog_item.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog_item.php&lt;br /&gt;
&lt;br /&gt;
When &amp;quot;Joomla!&amp;quot; is parsing the view, it will automatically know to load blog.php from com_content natively and blog_item.php from your template overrides.&lt;br /&gt;
== Module Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
Modules, like components, are set up in a particular directory structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/modules&lt;br /&gt;
  /mod_latest_news&lt;br /&gt;
	/tmpl&lt;br /&gt;
	  default.php	   (the layout)&lt;br /&gt;
	helper.php		  (a helper file containing data logic)&lt;br /&gt;
	mod_latest_news.php (the main module file)&lt;br /&gt;
	mod_latest_news.xml (the installation XML file)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Similar to components, under the main module directory (in the example, mod_latest_news) there is a /tmpl/ directory.  There is usually only one layout file but depending on who wrote the module, and how it is written, there could be more.&lt;br /&gt;
&lt;br /&gt;
As for components, the layout override for a module must be placed in particular way.  Using Beez as an example again, you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /mod_latest_news.php (this directory matches the module directory name)&lt;br /&gt;
		default.php		(this file matches the layout file name)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The structure for module overrides is again quite simple: /html/mod_module_name/layout_file_name.php.&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any modules.  If we want to override the default layout for Latest News module, we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the approriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
You need to take a little care with overriding module layout because there are a number of different ways that modules can or have been designed so you need to treat each one individually.&lt;br /&gt;
== Module Chrome ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.0 had a number of fixed styles that could display a list of modules in a particular position.  These where represented by numbers:&lt;br /&gt;
&lt;br /&gt;
* 0 (the default) displayed modules in a vertical table&lt;br /&gt;
* 1 displayed them in a horizontal table&lt;br /&gt;
* -1 displayed the raw module output&lt;br /&gt;
* -2 displayed the modules in a XHTML compatible format with the title in a H3 tag.&lt;br /&gt;
* -3 displayed modules in a set of nested DIVs that allowed for rounded-corner techniques&lt;br /&gt;
&lt;br /&gt;
It was a great system except for two things:&lt;br /&gt;
&lt;br /&gt;
# Nobody could remember which number was which, and&lt;br /&gt;
# You couldn&#039;t expand on the styles.&lt;br /&gt;
&lt;br /&gt;
Well, in 1.5, the numbers are still recognised, but more commonly the style is represented as a word.  As well as that, the syntax for displaying a module position was changed.  For example, this snippet displays each module in the left position in the xhtml style:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;jdoc:include type=&amp;quot;modules&amp;quot; name=&amp;quot;left&amp;quot; style=&amp;quot;xhtml&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The built-in styles that are now available are:&lt;br /&gt;
&lt;br /&gt;
* table (was 0 and is the default)&lt;br /&gt;
* horz (was 1)&lt;br /&gt;
* none (was -1)&lt;br /&gt;
* xhtml (was -2)&lt;br /&gt;
* rounded (was -3)&lt;br /&gt;
* outline (new - used to preview module positions - see screenshot above)&lt;br /&gt;
&lt;br /&gt;
In the source code, these styles are actually referred to ask &amp;quot;chrome&amp;quot;.  The default chrome can actually be found in the system template provided in the default &amp;quot;Joomla!&amp;quot; install:&lt;br /&gt;
&lt;br /&gt;
/templates/system/html/modules.php&lt;br /&gt;
&lt;br /&gt;
This file is maintained by the project so you should never modify it directly otherwise there is a risk that you will loose your changes if and when you upgrade your &amp;quot;Joomla!&amp;quot; installation.&lt;br /&gt;
&lt;br /&gt;
To create your own chrome, or module styles, all you need to do is create or edit modules.php under the templates /html/ directory (this is the same directory we have been talking about for component and module layout overrides).&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template actually does provide some extra chrome as an example (it provides and new example style called &amp;quot;slider&amp;quot;).  This can be found in the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
To create your own chrome is really easy.  Let&#039;s look at ficticious example that displays the module in a Definition List (a set of DL&#039;s, DT&#039;s and DD&#039;s).&lt;br /&gt;
&lt;br /&gt;
Just add the following function to the /html/modules.php file in your default template directory (create it if it does not exist):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * Module chrome that wraps the module in a definition list&lt;br /&gt;
 */&lt;br /&gt;
function modChrome_dlist($module, &amp;amp;$params, &amp;amp;$attribs)&lt;br /&gt;
{ ?&amp;gt;&lt;br /&gt;
	&amp;lt;dl class=&amp;quot;&amp;lt;?php echo $params-&amp;gt;get(&#039;moduleclass_sfx&#039;); ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;?php if ($module-&amp;gt;showtitle != 0) : ?&amp;gt;&lt;br /&gt;
		&amp;lt;dt&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;title; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dt&amp;gt;&lt;br /&gt;
	&amp;lt;?php endif; ?&amp;gt;&lt;br /&gt;
		&amp;lt;dd&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;content; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dd&amp;gt;&lt;br /&gt;
	&amp;lt;/dl&amp;gt;&lt;br /&gt;
	&amp;lt;?php&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We will be calling the style &amp;quot;dlist&amp;quot;, so the name of the function needs to be modChrome_dlist.&lt;br /&gt;
&lt;br /&gt;
The function must take the three arguments as shown for the module object, the module parameters, and lastly the $attribs is an array of all the attributes in the jdoc XML tag.&lt;br /&gt;
&lt;br /&gt;
There are three main properties in the module object to be concerned with:&lt;br /&gt;
&lt;br /&gt;
* showtitle tells you whether to show the title of the module of not&lt;br /&gt;
* title is the title of the module&lt;br /&gt;
* content is the output of the module (from its layout)&lt;br /&gt;
&lt;br /&gt;
This is a very simple case and you can of course design more complex styles, possibly using custom atrributes in the XML tag.&lt;br /&gt;
== Pagination Links Overrides ==&lt;br /&gt;
&lt;br /&gt;
The final override we will look at is the pagination override.  This override can control the display of items-per-page and the pagination links that are used with lists of information, as shown in the following screenshot.&lt;br /&gt;
&lt;br /&gt;
http://developer.joomla.org/images/tutorials/understanding_output/pagination_links.png&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template provides a well commented example for this override.  The file is found here:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
When the pagination list is required, &amp;quot;Joomla!&amp;quot; will look for this file in the default templates.  If it is found it will be loaded and the display functions it contains will be used.&lt;br /&gt;
&lt;br /&gt;
There are four functions that can be used:&lt;br /&gt;
&lt;br /&gt;
pagination_list_footer&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the select list for the number of items to display per page.&lt;br /&gt;
&lt;br /&gt;
pagination_list_render&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the list of page number links as well at the Start, End, Previous and Next links.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the links to other page numbers other than the &amp;quot;current&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the current page number, usually not hyperlinked.&lt;br /&gt;
== Cheat Sheet ==&lt;br /&gt;
&lt;br /&gt;
Using the rhuk_milkyway template as an example, here is a brief summary of the priniciples we&#039;ve looked at.&lt;br /&gt;
=== Customise the Component Output ===&lt;br /&gt;
&lt;br /&gt;
To override a component layout (for example the default layout in the article view), copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about component output.&lt;br /&gt;
=== Customise the Module Output ===&lt;br /&gt;
&lt;br /&gt;
To override a module layout (for example the Latest News module using the rhuk_milkyway template), copy:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about module output.&lt;br /&gt;
=== Add New Module Styles ===&lt;br /&gt;
&lt;br /&gt;
To add new module styles (chrome), add them to the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
Read more about module styles.&lt;br /&gt;
=== Customise the Pagination Links ===&lt;br /&gt;
&lt;br /&gt;
To customise the way the items-per-page selector and pagination links display, edit the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
Read more about pagination.&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.5, through the use of an MVC paradigm has greatly improved the flexibility that is afforded to Web site designers.  By way of a few simple principles, like copying certain files to certain places in your template, the designer is able to override almost all of the output generated by &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If you have any questions relating to output overrides please let us know so that we can improve this tutorial.&lt;br /&gt;
&lt;br /&gt;
If you have translated this article into another language, please let us know.&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8974</id>
		<title>Understanding Output Overrides</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8974"/>
		<updated>2008-07-05T14:08:45Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Template versus Layout */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Understanding Output Overrides in &amp;quot;Joomla!&amp;quot; 1.5 =&lt;br /&gt;
Written by Andrew Eddie&lt;br /&gt;
&lt;br /&gt;
This was Developer Blog post by Andrew, initially copied to the wiki with minor edits by Alan Langford. This is still a work in progress.&lt;br /&gt;
== Introduction ==&lt;br /&gt;
There are many competing requirements for web designers ranging from accessibility to legislative to personal preferences.  Rather than trying to over-parameterise views, or trying to aim for some sort of line of best fit, or worse, sticking its head in the sand, &amp;quot;Joomla!&amp;quot; has added the potential for the designer to take over control of virtually all of the output that is generated.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; has been criticized by some for not giving due attention to accessibility or being archaic in their approach to web standards. However with 1.5, the responsibility, but more importantly the power is back in the designer&#039;s hands.&lt;br /&gt;
&lt;br /&gt;
In addition, except for files that are provided in the &amp;quot;Joomla!&amp;quot; distribution itself, these methods for customisation eliminate the need for designers and developers to &amp;quot;hack&amp;quot; core files that could change when the site is updated to a new version.  Because they are contained within the template, they can be deployed to the Web site without having to worry about changes being accidentally overwritten when your System Administrator upgrades the site.&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to introduce the how fours areas of the output of &amp;quot;Joomla!&amp;quot; are able to be customised by the template designer.&lt;br /&gt;
&lt;br /&gt;
Not interested in all the theory?  Jump straight to the cheat sheet.&lt;br /&gt;
== MVC 101 ==&lt;br /&gt;
MVC can be a scary acronym.  It stands for Model-View-Controller and the concepts behind MVC are responsible for the extra flexibility that is now afforded to the designer.  While parts of the theory can be rather involved and complicated, the only part that the designer need worry about is the V for View.  This is the part that is concerned with output.&lt;br /&gt;
&lt;br /&gt;
Different extensions display output in different ways.&lt;br /&gt;
&lt;br /&gt;
Components, as you would already know, are fairly complex and have the ability to display different information in different ways.  For example, the Articles Component (com_content) is able to display a single article, or articles in a category, or categories in a section.  Each of the ways of representing the different types of data (an article, or a category, or a section) is called a &amp;quot;view&amp;quot; (this comes from our MVC terminology).  Most components will have many views.  However, the view doesn&#039;t actually display the output.  This is left up to what we call a &amp;quot;layout&amp;quot; and it is possible for a view to have a variety of layouts.&lt;br /&gt;
&lt;br /&gt;
The main thing to remember here is that components can have multiple views, and each view can have one or more layouts.  Each view assembles a fixed set of information, but each layout can display that information in different ways.  For example, the Category view in the Articles component assembles a number of articles.  These articles could be displayed in a list or in a table (and probably other ways as well).  So this view may have a &amp;quot;list&amp;quot; layout and a &amp;quot;table&amp;quot; layout to choose from.&lt;br /&gt;
&lt;br /&gt;
Modules, on the other hand, are very simple.  They generally display one thing one way.  Modules don&#039;t really have views but they do support a layout.  Some developers might even support a choice of layout through module parameters.&lt;br /&gt;
=== Template versus Layout ===&lt;br /&gt;
&lt;br /&gt;
It is very important to distinguish between the role of template and the role of layouts.  The template sets up a structural framework for the page of the Web site.  Within this framework are positions for modules and a component to display.  What actually gets displayed is governed by the module layout, or the combination of view and layout in the case of the component.&lt;br /&gt;
&lt;br /&gt;
The following image shows the structural layout of a typical &amp;quot;Joomla!&amp;quot; template (rhuk_milkyway, the default for 1.5).  The module positions are displayed by adding tp=1 to the URL (eg, index.php?tp=1).  You can clearly see where the module output is contained within the overall template, as well as the main component output starting in the lower-centre region.  However, what is actually output in those regions, is controlled by the layouts.&lt;br /&gt;
&lt;br /&gt;
[[Image:ForntpageTemplatePositions.png|Typical Joomla! screenshot with template positions shown.]]&lt;br /&gt;
&lt;br /&gt;
=== Ancillary Customisation ===&lt;br /&gt;
&lt;br /&gt;
While not strictly related to the MVC, there are two other important areas to consider when looking at customising the output of &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In addition to layouts, modules have what we call &amp;quot;chrome&amp;quot;.  Chrome is the style with which a module is to display.  Most developers, designers and probably some end-users will be familiar with the different built-in styles for modules (raw, xhtml, etc).  It is also possible to define your own chrome styles for modules depending on the designer result.  For example, you could design a chrome to display all the modules in a particular position in a fancy Javascript collapsing blind arrangement.&lt;br /&gt;
&lt;br /&gt;
In the screenshot above, you can just make out the names of some of the built-in module chrome used (rounded, none and xhtml).&lt;br /&gt;
&lt;br /&gt;
The second area has to do with controlling the pagination controls when viewing lists of data.  We will look at that in more detail later.&lt;br /&gt;
== Component Output Types and Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
To understand layout overrides we must first understand the file structure of a component.  While there are many parts to a component, all fulfilling different roles and responsibilities, we want to look just in the /views/ directory.  Here is the partial structure for two of the com_content views:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/components&lt;br /&gt;
  /com_content&lt;br /&gt;
	/views&lt;br /&gt;
	  /articles&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  default.php (this is a layout)&lt;br /&gt;
		  form.php	(this is a layout)&lt;br /&gt;
		view.html.php (this is the view that outputs the HTML)&lt;br /&gt;
		view.pdf.php  (this is the view that outputs the PDF)&lt;br /&gt;
	  /category&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  blog.php	   (layout)&lt;br /&gt;
		  blog_items.php (a sub-layout&lt;br /&gt;
		  default.php	(layout)&lt;br /&gt;
		view.html.php	(HTML view)&lt;br /&gt;
		view.feed.php	(RSS feed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
So what you see here is that under the /views/ directory, each view is placed in a directory of its own.  The content component actually has three other views not shown: archive, frontpage and section.&lt;br /&gt;
=== Output Types ===&lt;br /&gt;
Under the /articles/ directory we have a number of files.  There is almost always a file called view.html.php.  This is what we call the view file, but there can be more than one depending on the type of output to produce.  It has a specific naming convention, view.output_type.php, where the output type can be html, feed, pdf, raw or error (for more information see JDocument in the API reference and look in the directory /libraries/joomla/document/).  What this means is when we want html output for this particular view, the view.html.php file is used.  When we want the RSS output, the view.feed.php file is used.&lt;br /&gt;
&lt;br /&gt;
The affect of these different output types is most apparent when the Global Configuration setting for Search Engine Friendly URLs is set to Yes, Use Apache mod_rewrite is set to Yes, and Add suffix to URLs is also set to Yes.  When this is done, the site URLs will look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://domain/sports.html&lt;br /&gt;
http://domain/sports.feed&lt;br /&gt;
http://domain/sports/rowing.html&lt;br /&gt;
http://domain/sports/rowing.pdf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The exact URL will vary depending on how you set up your site but the point here is to show that sports.html will use the category view&#039;s view.html.php file to, and that sports.feed will display the RSS feed for the category using view.feed.php.  It should be noted that you cannot currently customise feed or PDF output types.  However, you can customise the html output type and this is where layouts come into play.&lt;br /&gt;
&lt;br /&gt;
=== Layouts ===&lt;br /&gt;
Under the view directory there is a /tmpl/ directory in which the layout files reside.  Each PHP file in this directory represents a layout.  For example, article/tmpl/default.php is the default layout for an article whereas article/tmpl/form.php is the edit form for an article; category/tmpl/default.php is the default layout for a category whereas category/tmpl/blog.php displays the list of article differently.&lt;br /&gt;
&lt;br /&gt;
The relationship between component views and layout is most plainly seen when adding a new menu item.  The next screenshot represents the typical display of the New Menu Item page.  Having clicked on Articles (which represents com_content), the tree expands to show the list of views and each layout within the view.&lt;br /&gt;
&lt;br /&gt;
http://developer.joomla.org/images/tutorials/understanding_output/menu_item_new.png&lt;br /&gt;
&lt;br /&gt;
You will notice that while there are extra files in some of the /tmpl/ directories (like pagebreak.php in the article view), they are missing from the list.  This is due to instructions in the XML file for the layout (for example, pagebreak.xml) to hide the layout (or even the view) from the menu item list.  However, this is another broad topic which will be covered in another tutorial.&lt;br /&gt;
&lt;br /&gt;
Armed with all that knowledge of how all the parts relate to each other, we are now ready to actually create our layout overrides.&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
Layout overrides only work within the active template and are located under the /html/ directory in the template.  For example, the overrides for rhuk_milkyway are located under /templates/rhuk_milkyway/html/, for the JA Purity template under /templates/ja_purity/html/ and for Beez under /templates/beez/html/.&lt;br /&gt;
&lt;br /&gt;
It is important to understand that if you create overrides in one template, they will not be available in other templates.  For example, rhuk_milkyway has no component layout overrides at all.  When you use this template you are seeing the raw output from all components.  When you use the Beez template, almost every piece of component output is being controlled by the layout overrides in the template.  JA Purity is in between having overrides for some components and only some views of those components.&lt;br /&gt;
&lt;br /&gt;
The layout overrides must be placed in particular way.  Using Beez as an example you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /com_content	(this directory matches the component directory name)&lt;br /&gt;
		/articles	 (this directory matches the view directory name)&lt;br /&gt;
		  default.php (this file matches the layout file name)&lt;br /&gt;
		  form.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure for component overrides is quite simple: /html/com_component_name/view_name/layout_file_name.php.  Let&#039;s look at a few examples.&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any components.  If we want to override the default layout for an article, first we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the appropriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
If we wanted to override the blog layout in the category view, we would copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog.php&lt;br /&gt;
&lt;br /&gt;
Once the files are copied, you are free to customise these files as much or as little as required or desired.  You do not have to honour parameter settings if you don&#039;t want to.&lt;br /&gt;
=== Overriding Sub-Layouts ===&lt;br /&gt;
&lt;br /&gt;
In some views you will see that some of the layouts have a group of files that start with the same name.  The category view has an example of this.  The blog layout actually has three parts: the main layout file blog.php and two sub-layout files, blog_item.php and blog_links.php.  You can see where these sub-layouts are loaded in the blog.php file using the loadTemplate method, for example:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;item&#039;);&lt;br /&gt;
// or&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;links&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
When loading sub-layouts, the view already knows what layout you are in, so you don&#039;t have to provide the prefix (that is, you load just &#039;item&#039;, not &#039;blog_item&#039;).&lt;br /&gt;
&lt;br /&gt;
What is important to note here is that it is possible to override just a sub-layout without copying the whole set of files.  For example, if you were happy with the &amp;quot;Joomla!&amp;quot; default output for the blog layout, but just wanted to customise the item sub-layout, you could just copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog_item.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog_item.php&lt;br /&gt;
&lt;br /&gt;
When &amp;quot;Joomla!&amp;quot; is parsing the view, it will automatically know to load blog.php from com_content natively and blog_item.php from your template overrides.&lt;br /&gt;
== Module Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
Modules, like components, are set up in a particular directory structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/modules&lt;br /&gt;
  /mod_latest_news&lt;br /&gt;
	/tmpl&lt;br /&gt;
	  default.php	   (the layout)&lt;br /&gt;
	helper.php		  (a helper file containing data logic)&lt;br /&gt;
	mod_latest_news.php (the main module file)&lt;br /&gt;
	mod_latest_news.xml (the installation XML file)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Similar to components, under the main module directory (in the example, mod_latest_news) there is a /tmpl/ directory.  There is usually only one layout file but depending on who wrote the module, and how it is written, there could be more.&lt;br /&gt;
&lt;br /&gt;
As for components, the layout override for a module must be placed in particular way.  Using Beez as an example again, you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /mod_latest_news.php (this directory matches the module directory name)&lt;br /&gt;
		default.php		(this file matches the layout file name)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The structure for module overrides is again quite simple: /html/mod_module_name/layout_file_name.php.&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any modules.  If we want to override the default layout for Latest News module, we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the approriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
You need to take a little care with overriding module layout because there are a number of different ways that modules can or have been designed so you need to treat each one individually.&lt;br /&gt;
== Module Chrome ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.0 had a number of fixed styles that could display a list of modules in a particular position.  These where represented by numbers:&lt;br /&gt;
&lt;br /&gt;
* 0 (the default) displayed modules in a vertical table&lt;br /&gt;
* 1 displayed them in a horizontal table&lt;br /&gt;
* -1 displayed the raw module output&lt;br /&gt;
* -2 displayed the modules in a XHTML compatible format with the title in a H3 tag.&lt;br /&gt;
* -3 displayed modules in a set of nested DIVs that allowed for rounded-corner techniques&lt;br /&gt;
&lt;br /&gt;
It was a great system except for two things:&lt;br /&gt;
&lt;br /&gt;
# Nobody could remember which number was which, and&lt;br /&gt;
# You couldn&#039;t expand on the styles.&lt;br /&gt;
&lt;br /&gt;
Well, in 1.5, the numbers are still recognised, but more commonly the style is represented as a word.  As well as that, the syntax for displaying a module position was changed.  For example, this snippet displays each module in the left position in the xhtml style:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;jdoc:include type=&amp;quot;modules&amp;quot; name=&amp;quot;left&amp;quot; style=&amp;quot;xhtml&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The built-in styles that are now available are:&lt;br /&gt;
&lt;br /&gt;
* table (was 0 and is the default)&lt;br /&gt;
* horz (was 1)&lt;br /&gt;
* none (was -1)&lt;br /&gt;
* xhtml (was -2)&lt;br /&gt;
* rounded (was -3)&lt;br /&gt;
* outline (new - used to preview module positions - see screenshot above)&lt;br /&gt;
&lt;br /&gt;
In the source code, these styles are actually referred to ask &amp;quot;chrome&amp;quot;.  The default chrome can actually be found in the system template provided in the default &amp;quot;Joomla!&amp;quot; install:&lt;br /&gt;
&lt;br /&gt;
/templates/system/html/modules.php&lt;br /&gt;
&lt;br /&gt;
This file is maintained by the project so you should never modify it directly otherwise there is a risk that you will loose your changes if and when you upgrade your &amp;quot;Joomla!&amp;quot; installation.&lt;br /&gt;
&lt;br /&gt;
To create your own chrome, or module styles, all you need to do is create or edit modules.php under the templates /html/ directory (this is the same directory we have been talking about for component and module layout overrides).&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template actually does provide some extra chrome as an example (it provides and new example style called &amp;quot;slider&amp;quot;).  This can be found in the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
To create your own chrome is really easy.  Let&#039;s look at ficticious example that displays the module in a Definition List (a set of DL&#039;s, DT&#039;s and DD&#039;s).&lt;br /&gt;
&lt;br /&gt;
Just add the following function to the /html/modules.php file in your default template directory (create it if it does not exist):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * Module chrome that wraps the module in a definition list&lt;br /&gt;
 */&lt;br /&gt;
function modChrome_dlist($module, &amp;amp;$params, &amp;amp;$attribs)&lt;br /&gt;
{ ?&amp;gt;&lt;br /&gt;
	&amp;lt;dl class=&amp;quot;&amp;lt;?php echo $params-&amp;gt;get(&#039;moduleclass_sfx&#039;); ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;?php if ($module-&amp;gt;showtitle != 0) : ?&amp;gt;&lt;br /&gt;
		&amp;lt;dt&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;title; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dt&amp;gt;&lt;br /&gt;
	&amp;lt;?php endif; ?&amp;gt;&lt;br /&gt;
		&amp;lt;dd&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;content; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dd&amp;gt;&lt;br /&gt;
	&amp;lt;/dl&amp;gt;&lt;br /&gt;
	&amp;lt;?php&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We will be calling the style &amp;quot;dlist&amp;quot;, so the name of the function needs to be modChrome_dlist.&lt;br /&gt;
&lt;br /&gt;
The function must take the three arguments as shown for the module object, the module parameters, and lastly the $attribs is an array of all the attributes in the jdoc XML tag.&lt;br /&gt;
&lt;br /&gt;
There are three main properties in the module object to be concerned with:&lt;br /&gt;
&lt;br /&gt;
* showtitle tells you whether to show the title of the module of not&lt;br /&gt;
* title is the title of the module&lt;br /&gt;
* content is the output of the module (from its layout)&lt;br /&gt;
&lt;br /&gt;
This is a very simple case and you can of course design more complex styles, possibly using custom atrributes in the XML tag.&lt;br /&gt;
== Pagination Links Overrides ==&lt;br /&gt;
&lt;br /&gt;
The final override we will look at is the pagination override.  This override can control the display of items-per-page and the pagination links that are used with lists of information, as shown in the following screenshot.&lt;br /&gt;
&lt;br /&gt;
http://developer.joomla.org/images/tutorials/understanding_output/pagination_links.png&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template provides a well commented example for this override.  The file is found here:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
When the pagination list is required, &amp;quot;Joomla!&amp;quot; will look for this file in the default templates.  If it is found it will be loaded and the display functions it contains will be used.&lt;br /&gt;
&lt;br /&gt;
There are four functions that can be used:&lt;br /&gt;
&lt;br /&gt;
pagination_list_footer&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the select list for the number of items to display per page.&lt;br /&gt;
&lt;br /&gt;
pagination_list_render&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the list of page number links as well at the Start, End, Previous and Next links.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the links to other page numbers other than the &amp;quot;current&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the current page number, usually not hyperlinked.&lt;br /&gt;
== Cheat Sheet ==&lt;br /&gt;
&lt;br /&gt;
Using the rhuk_milkyway template as an example, here is a brief summary of the priniciples we&#039;ve looked at.&lt;br /&gt;
=== Customise the Component Output ===&lt;br /&gt;
&lt;br /&gt;
To override a component layout (for example the default layout in the article view), copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about component output.&lt;br /&gt;
=== Customise the Module Output ===&lt;br /&gt;
&lt;br /&gt;
To override a module layout (for example the Latest News module using the rhuk_milkyway template), copy:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about module output.&lt;br /&gt;
=== Add New Module Styles ===&lt;br /&gt;
&lt;br /&gt;
To add new module styles (chrome), add them to the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
Read more about module styles.&lt;br /&gt;
=== Customise the Pagination Links ===&lt;br /&gt;
&lt;br /&gt;
To customise the way the items-per-page selector and pagination links display, edit the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
Read more about pagination.&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.5, through the use of an MVC paradigm has greatly improved the flexibility that is afforded to Web site designers.  By way of a few simple principles, like copying certain files to certain places in your template, the designer is able to override almost all of the output generated by &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If you have any questions relating to output overrides please let us know so that we can improve this tutorial.&lt;br /&gt;
&lt;br /&gt;
If you have translated this article into another language, please let us know.&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=File:FrontpageTemplatePositions.png&amp;diff=8973</id>
		<title>File:FrontpageTemplatePositions.png</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=File:FrontpageTemplatePositions.png&amp;diff=8973"/>
		<updated>2008-07-05T14:05:37Z</updated>

		<summary type="html">&lt;p&gt;Instance: Typical &amp;quot;Joomla!&amp;quot; screenshot with template positions shown.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
Typical &amp;quot;Joomla!&amp;quot; screenshot with template positions shown.&lt;br /&gt;
== Licensing ==&lt;br /&gt;
{{JEDL}}&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8972</id>
		<title>Understanding Output Overrides</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Understanding_Output_Overrides&amp;diff=8972"/>
		<updated>2008-07-05T13:57:29Z</updated>

		<summary type="html">&lt;p&gt;Instance: Wikification of Andrew&amp;#039;s blog post.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Understanding Output Overrides in &amp;quot;Joomla!&amp;quot; 1.5 =&lt;br /&gt;
Written by Andrew Eddie&lt;br /&gt;
&lt;br /&gt;
This was Developer Blog post by Andrew, initially copied to the wiki with minor edits by Alan Langford. This is still a work in progress.&lt;br /&gt;
== Introduction ==&lt;br /&gt;
There are many competing requirements for web designers ranging from accessibility to legislative to personal preferences.  Rather than trying to over-parameterise views, or trying to aim for some sort of line of best fit, or worse, sticking its head in the sand, &amp;quot;Joomla!&amp;quot; has added the potential for the designer to take over control of virtually all of the output that is generated.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; has been criticized by some for not giving due attention to accessibility or being archaic in their approach to web standards. However with 1.5, the responsibility, but more importantly the power is back in the designer&#039;s hands.&lt;br /&gt;
&lt;br /&gt;
In addition, except for files that are provided in the &amp;quot;Joomla!&amp;quot; distribution itself, these methods for customisation eliminate the need for designers and developers to &amp;quot;hack&amp;quot; core files that could change when the site is updated to a new version.  Because they are contained within the template, they can be deployed to the Web site without having to worry about changes being accidentally overwritten when your System Administrator upgrades the site.&lt;br /&gt;
&lt;br /&gt;
The aim of this tutorial is to introduce the how fours areas of the output of &amp;quot;Joomla!&amp;quot; are able to be customised by the template designer.&lt;br /&gt;
&lt;br /&gt;
Not interested in all the theory?  Jump straight to the cheat sheet.&lt;br /&gt;
== MVC 101 ==&lt;br /&gt;
MVC can be a scary acronym.  It stands for Model-View-Controller and the concepts behind MVC are responsible for the extra flexibility that is now afforded to the designer.  While parts of the theory can be rather involved and complicated, the only part that the designer need worry about is the V for View.  This is the part that is concerned with output.&lt;br /&gt;
&lt;br /&gt;
Different extensions display output in different ways.&lt;br /&gt;
&lt;br /&gt;
Components, as you would already know, are fairly complex and have the ability to display different information in different ways.  For example, the Articles Component (com_content) is able to display a single article, or articles in a category, or categories in a section.  Each of the ways of representing the different types of data (an article, or a category, or a section) is called a &amp;quot;view&amp;quot; (this comes from our MVC terminology).  Most components will have many views.  However, the view doesn&#039;t actually display the output.  This is left up to what we call a &amp;quot;layout&amp;quot; and it is possible for a view to have a variety of layouts.&lt;br /&gt;
&lt;br /&gt;
The main thing to remember here is that components can have multiple views, and each view can have one or more layouts.  Each view assembles a fixed set of information, but each layout can display that information in different ways.  For example, the Category view in the Articles component assembles a number of articles.  These articles could be displayed in a list or in a table (and probably other ways as well).  So this view may have a &amp;quot;list&amp;quot; layout and a &amp;quot;table&amp;quot; layout to choose from.&lt;br /&gt;
&lt;br /&gt;
Modules, on the other hand, are very simple.  They generally display one thing one way.  Modules don&#039;t really have views but they do support a layout.  Some developers might even support a choice of layout through module parameters.&lt;br /&gt;
=== Template versus Layout ===&lt;br /&gt;
&lt;br /&gt;
It is very important to distinguish between the role of template and the role of layouts.  The template sets up a structural framework for the page of the Web site.  Within this framework are positions for modules and a component to display.  What actually gets displayed is governed by the module layout, or the combination of view and layout in the case of the component.&lt;br /&gt;
&lt;br /&gt;
The following image shows the structural layout of a typical &amp;quot;Joomla!&amp;quot; template (rhuk_milkyway, the default for 1.5).  The module positions are displayed by adding tp=1 to the URL (eg, index.php?tp=1).  You can clearly see where the module output is contained within the overall template, as well as the main component output starting in the lower-centre region.  However, what is actually output in those regions, is controlled by the layouts.&lt;br /&gt;
&lt;br /&gt;
http://developer.joomla.org/images/tutorials/understanding_output/frontpage_tp1.png&lt;br /&gt;
=== Ancillary Customisation ===&lt;br /&gt;
&lt;br /&gt;
While not strictly related to the MVC, there are two other important areas to consider when looking at customising the output of &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In addition to layouts, modules have what we call &amp;quot;chrome&amp;quot;.  Chrome is the style with which a module is to display.  Most developers, designers and probably some end-users will be familiar with the different built-in styles for modules (raw, xhtml, etc).  It is also possible to define your own chrome styles for modules depending on the designer result.  For example, you could design a chrome to display all the modules in a particular position in a fancy Javascript collapsing blind arrangement.&lt;br /&gt;
&lt;br /&gt;
In the screenshot above, you can just make out the names of some of the built-in module chrome used (rounded, none and xhtml).&lt;br /&gt;
&lt;br /&gt;
The second area has to do with controlling the pagination controls when viewing lists of data.  We will look at that in more detail later.&lt;br /&gt;
== Component Output Types and Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
To understand layout overrides we must first understand the file structure of a component.  While there are many parts to a component, all fulfilling different roles and responsibilities, we want to look just in the /views/ directory.  Here is the partial structure for two of the com_content views:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/components&lt;br /&gt;
  /com_content&lt;br /&gt;
	/views&lt;br /&gt;
	  /articles&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  default.php (this is a layout)&lt;br /&gt;
		  form.php	(this is a layout)&lt;br /&gt;
		view.html.php (this is the view that outputs the HTML)&lt;br /&gt;
		view.pdf.php  (this is the view that outputs the PDF)&lt;br /&gt;
	  /category&lt;br /&gt;
		/tmpl&lt;br /&gt;
		  blog.php	   (layout)&lt;br /&gt;
		  blog_items.php (a sub-layout&lt;br /&gt;
		  default.php	(layout)&lt;br /&gt;
		view.html.php	(HTML view)&lt;br /&gt;
		view.feed.php	(RSS feed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
So what you see here is that under the /views/ directory, each view is placed in a directory of its own.  The content component actually has three other views not shown: archive, frontpage and section.&lt;br /&gt;
=== Output Types ===&lt;br /&gt;
Under the /articles/ directory we have a number of files.  There is almost always a file called view.html.php.  This is what we call the view file, but there can be more than one depending on the type of output to produce.  It has a specific naming convention, view.output_type.php, where the output type can be html, feed, pdf, raw or error (for more information see JDocument in the API reference and look in the directory /libraries/joomla/document/).  What this means is when we want html output for this particular view, the view.html.php file is used.  When we want the RSS output, the view.feed.php file is used.&lt;br /&gt;
&lt;br /&gt;
The affect of these different output types is most apparent when the Global Configuration setting for Search Engine Friendly URLs is set to Yes, Use Apache mod_rewrite is set to Yes, and Add suffix to URLs is also set to Yes.  When this is done, the site URLs will look something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://domain/sports.html&lt;br /&gt;
http://domain/sports.feed&lt;br /&gt;
http://domain/sports/rowing.html&lt;br /&gt;
http://domain/sports/rowing.pdf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The exact URL will vary depending on how you set up your site but the point here is to show that sports.html will use the category view&#039;s view.html.php file to, and that sports.feed will display the RSS feed for the category using view.feed.php.  It should be noted that you cannot currently customise feed or PDF output types.  However, you can customise the html output type and this is where layouts come into play.&lt;br /&gt;
&lt;br /&gt;
=== Layouts ===&lt;br /&gt;
Under the view directory there is a /tmpl/ directory in which the layout files reside.  Each PHP file in this directory represents a layout.  For example, article/tmpl/default.php is the default layout for an article whereas article/tmpl/form.php is the edit form for an article; category/tmpl/default.php is the default layout for a category whereas category/tmpl/blog.php displays the list of article differently.&lt;br /&gt;
&lt;br /&gt;
The relationship between component views and layout is most plainly seen when adding a new menu item.  The next screenshot represents the typical display of the New Menu Item page.  Having clicked on Articles (which represents com_content), the tree expands to show the list of views and each layout within the view.&lt;br /&gt;
&lt;br /&gt;
http://developer.joomla.org/images/tutorials/understanding_output/menu_item_new.png&lt;br /&gt;
&lt;br /&gt;
You will notice that while there are extra files in some of the /tmpl/ directories (like pagebreak.php in the article view), they are missing from the list.  This is due to instructions in the XML file for the layout (for example, pagebreak.xml) to hide the layout (or even the view) from the menu item list.  However, this is another broad topic which will be covered in another tutorial.&lt;br /&gt;
&lt;br /&gt;
Armed with all that knowledge of how all the parts relate to each other, we are now ready to actually create our layout overrides.&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
Layout overrides only work within the active template and are located under the /html/ directory in the template.  For example, the overrides for rhuk_milkyway are located under /templates/rhuk_milkyway/html/, for the JA Purity template under /templates/ja_purity/html/ and for Beez under /templates/beez/html/.&lt;br /&gt;
&lt;br /&gt;
It is important to understand that if you create overrides in one template, they will not be available in other templates.  For example, rhuk_milkyway has no component layout overrides at all.  When you use this template you are seeing the raw output from all components.  When you use the Beez template, almost every piece of component output is being controlled by the layout overrides in the template.  JA Purity is in between having overrides for some components and only some views of those components.&lt;br /&gt;
&lt;br /&gt;
The layout overrides must be placed in particular way.  Using Beez as an example you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /com_content	(this directory matches the component directory name)&lt;br /&gt;
		/articles	 (this directory matches the view directory name)&lt;br /&gt;
		  default.php (this file matches the layout file name)&lt;br /&gt;
		  form.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The structure for component overrides is quite simple: /html/com_component_name/view_name/layout_file_name.php.  Let&#039;s look at a few examples.&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any components.  If we want to override the default layout for an article, first we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the appropriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
If we wanted to override the blog layout in the category view, we would copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog.php&lt;br /&gt;
&lt;br /&gt;
Once the files are copied, you are free to customise these files as much or as little as required or desired.  You do not have to honour parameter settings if you don&#039;t want to.&lt;br /&gt;
=== Overriding Sub-Layouts ===&lt;br /&gt;
&lt;br /&gt;
In some views you will see that some of the layouts have a group of files that start with the same name.  The category view has an example of this.  The blog layout actually has three parts: the main layout file blog.php and two sub-layout files, blog_item.php and blog_links.php.  You can see where these sub-layouts are loaded in the blog.php file using the loadTemplate method, for example:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;item&#039;);&lt;br /&gt;
// or&lt;br /&gt;
echo $this-&amp;gt;loadTemplate(&#039;links&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
When loading sub-layouts, the view already knows what layout you are in, so you don&#039;t have to provide the prefix (that is, you load just &#039;item&#039;, not &#039;blog_item&#039;).&lt;br /&gt;
&lt;br /&gt;
What is important to note here is that it is possible to override just a sub-layout without copying the whole set of files.  For example, if you were happy with the &amp;quot;Joomla!&amp;quot; default output for the blog layout, but just wanted to customise the item sub-layout, you could just copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/category/tmpl/blog_item.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/category/blog_item.php&lt;br /&gt;
&lt;br /&gt;
When &amp;quot;Joomla!&amp;quot; is parsing the view, it will automatically know to load blog.php from com_content natively and blog_item.php from your template overrides.&lt;br /&gt;
== Module Layout Overrides ==&lt;br /&gt;
&lt;br /&gt;
Modules, like components, are set up in a particular directory structure.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/modules&lt;br /&gt;
  /mod_latest_news&lt;br /&gt;
	/tmpl&lt;br /&gt;
	  default.php	   (the layout)&lt;br /&gt;
	helper.php		  (a helper file containing data logic)&lt;br /&gt;
	mod_latest_news.php (the main module file)&lt;br /&gt;
	mod_latest_news.xml (the installation XML file)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Similar to components, under the main module directory (in the example, mod_latest_news) there is a /tmpl/ directory.  There is usually only one layout file but depending on who wrote the module, and how it is written, there could be more.&lt;br /&gt;
&lt;br /&gt;
As for components, the layout override for a module must be placed in particular way.  Using Beez as an example again, you will see the following structure:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/templates&lt;br /&gt;
  /beez&lt;br /&gt;
	/html&lt;br /&gt;
	  /mod_latest_news.php (this directory matches the module directory name)&lt;br /&gt;
		default.php		(this file matches the layout file name)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The structure for module overrides is again quite simple: /html/mod_module_name/layout_file_name.php.&lt;br /&gt;
=== Copying or Creating Layout Files ===&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template does not have any layout overrides for any modules.  If we want to override the default layout for Latest News module, we need to copy this file:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to this location, creating the approriate directories in the event they don&#039;t already exist:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
You need to take a little care with overriding module layout because there are a number of different ways that modules can or have been designed so you need to treat each one individually.&lt;br /&gt;
== Module Chrome ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.0 had a number of fixed styles that could display a list of modules in a particular position.  These where represented by numbers:&lt;br /&gt;
&lt;br /&gt;
* 0 (the default) displayed modules in a vertical table&lt;br /&gt;
* 1 displayed them in a horizontal table&lt;br /&gt;
* -1 displayed the raw module output&lt;br /&gt;
* -2 displayed the modules in a XHTML compatible format with the title in a H3 tag.&lt;br /&gt;
* -3 displayed modules in a set of nested DIVs that allowed for rounded-corner techniques&lt;br /&gt;
&lt;br /&gt;
It was a great system except for two things:&lt;br /&gt;
&lt;br /&gt;
# Nobody could remember which number was which, and&lt;br /&gt;
# You couldn&#039;t expand on the styles.&lt;br /&gt;
&lt;br /&gt;
Well, in 1.5, the numbers are still recognised, but more commonly the style is represented as a word.  As well as that, the syntax for displaying a module position was changed.  For example, this snippet displays each module in the left position in the xhtml style:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;jdoc:include type=&amp;quot;modules&amp;quot; name=&amp;quot;left&amp;quot; style=&amp;quot;xhtml&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The built-in styles that are now available are:&lt;br /&gt;
&lt;br /&gt;
* table (was 0 and is the default)&lt;br /&gt;
* horz (was 1)&lt;br /&gt;
* none (was -1)&lt;br /&gt;
* xhtml (was -2)&lt;br /&gt;
* rounded (was -3)&lt;br /&gt;
* outline (new - used to preview module positions - see screenshot above)&lt;br /&gt;
&lt;br /&gt;
In the source code, these styles are actually referred to ask &amp;quot;chrome&amp;quot;.  The default chrome can actually be found in the system template provided in the default &amp;quot;Joomla!&amp;quot; install:&lt;br /&gt;
&lt;br /&gt;
/templates/system/html/modules.php&lt;br /&gt;
&lt;br /&gt;
This file is maintained by the project so you should never modify it directly otherwise there is a risk that you will loose your changes if and when you upgrade your &amp;quot;Joomla!&amp;quot; installation.&lt;br /&gt;
&lt;br /&gt;
To create your own chrome, or module styles, all you need to do is create or edit modules.php under the templates /html/ directory (this is the same directory we have been talking about for component and module layout overrides).&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template actually does provide some extra chrome as an example (it provides and new example style called &amp;quot;slider&amp;quot;).  This can be found in the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
To create your own chrome is really easy.  Let&#039;s look at ficticious example that displays the module in a Definition List (a set of DL&#039;s, DT&#039;s and DD&#039;s).&lt;br /&gt;
&lt;br /&gt;
Just add the following function to the /html/modules.php file in your default template directory (create it if it does not exist):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * Module chrome that wraps the module in a definition list&lt;br /&gt;
 */&lt;br /&gt;
function modChrome_dlist($module, &amp;amp;$params, &amp;amp;$attribs)&lt;br /&gt;
{ ?&amp;gt;&lt;br /&gt;
	&amp;lt;dl class=&amp;quot;&amp;lt;?php echo $params-&amp;gt;get(&#039;moduleclass_sfx&#039;); ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;?php if ($module-&amp;gt;showtitle != 0) : ?&amp;gt;&lt;br /&gt;
		&amp;lt;dt&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;title; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dt&amp;gt;&lt;br /&gt;
	&amp;lt;?php endif; ?&amp;gt;&lt;br /&gt;
		&amp;lt;dd&amp;gt;&lt;br /&gt;
			&amp;lt;?php echo $module-&amp;gt;content; ?&amp;gt;&lt;br /&gt;
		&amp;lt;/dd&amp;gt;&lt;br /&gt;
	&amp;lt;/dl&amp;gt;&lt;br /&gt;
	&amp;lt;?php&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We will be calling the style &amp;quot;dlist&amp;quot;, so the name of the function needs to be modChrome_dlist.&lt;br /&gt;
&lt;br /&gt;
The function must take the three arguments as shown for the module object, the module parameters, and lastly the $attribs is an array of all the attributes in the jdoc XML tag.&lt;br /&gt;
&lt;br /&gt;
There are three main properties in the module object to be concerned with:&lt;br /&gt;
&lt;br /&gt;
* showtitle tells you whether to show the title of the module of not&lt;br /&gt;
* title is the title of the module&lt;br /&gt;
* content is the output of the module (from its layout)&lt;br /&gt;
&lt;br /&gt;
This is a very simple case and you can of course design more complex styles, possibly using custom atrributes in the XML tag.&lt;br /&gt;
== Pagination Links Overrides ==&lt;br /&gt;
&lt;br /&gt;
The final override we will look at is the pagination override.  This override can control the display of items-per-page and the pagination links that are used with lists of information, as shown in the following screenshot.&lt;br /&gt;
&lt;br /&gt;
http://developer.joomla.org/images/tutorials/understanding_output/pagination_links.png&lt;br /&gt;
&lt;br /&gt;
The rhuk_milkyway template provides a well commented example for this override.  The file is found here:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
When the pagination list is required, &amp;quot;Joomla!&amp;quot; will look for this file in the default templates.  If it is found it will be loaded and the display functions it contains will be used.&lt;br /&gt;
&lt;br /&gt;
There are four functions that can be used:&lt;br /&gt;
&lt;br /&gt;
pagination_list_footer&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the select list for the number of items to display per page.&lt;br /&gt;
&lt;br /&gt;
pagination_list_render&lt;br /&gt;
&lt;br /&gt;
This function is responsible for showing the list of page number links as well at the Start, End, Previous and Next links.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the links to other page numbers other than the &amp;quot;current&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
pagination_item_active&lt;br /&gt;
&lt;br /&gt;
This function displays the current page number, usually not hyperlinked.&lt;br /&gt;
== Cheat Sheet ==&lt;br /&gt;
&lt;br /&gt;
Using the rhuk_milkyway template as an example, here is a brief summary of the priniciples we&#039;ve looked at.&lt;br /&gt;
=== Customise the Component Output ===&lt;br /&gt;
&lt;br /&gt;
To override a component layout (for example the default layout in the article view), copy:&lt;br /&gt;
&lt;br /&gt;
/components/com_content/views/article/tmpl/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/com_content/article/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about component output.&lt;br /&gt;
=== Customise the Module Output ===&lt;br /&gt;
&lt;br /&gt;
To override a module layout (for example the Latest News module using the rhuk_milkyway template), copy:&lt;br /&gt;
&lt;br /&gt;
/components/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
to:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/mod_latest_news/default.php&lt;br /&gt;
&lt;br /&gt;
Read more about module output.&lt;br /&gt;
=== Add New Module Styles ===&lt;br /&gt;
&lt;br /&gt;
To add new module styles (chrome), add them to the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/modules.php&lt;br /&gt;
&lt;br /&gt;
Read more about module styles.&lt;br /&gt;
=== Customise the Pagination Links ===&lt;br /&gt;
&lt;br /&gt;
To customise the way the items-per-page selector and pagination links display, edit the following file:&lt;br /&gt;
&lt;br /&gt;
/templates/rhuk_milkyway/html/pagination.php&lt;br /&gt;
&lt;br /&gt;
Read more about pagination.&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Joomla!&amp;quot; 1.5, through the use of an MVC paradigm has greatly improved the flexibility that is afforded to Web site designers.  By way of a few simple principles, like copying certain files to certain places in your template, the designer is able to override almost all of the output generated by &amp;quot;Joomla!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If you have any questions relating to output overrides please let us know so that we can improve this tutorial.&lt;br /&gt;
&lt;br /&gt;
If you have translated this article into another language, please let us know.&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=J1.5:Template_FAQs&amp;diff=8935</id>
		<title>J1.5:Template FAQs</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=J1.5:Template_FAQs&amp;diff=8935"/>
		<updated>2008-07-02T18:05:30Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* CSS Text/Font Resizing (A+ A-) on Joomla Template */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{review}}&lt;br /&gt;
&lt;br /&gt;
===What is a template?===&lt;br /&gt;
&lt;br /&gt;
The [[Template]] controls the overall look and layout of your site. It provides the framework that brings together common elements, [[Modules|modules]] and [[Components|components]] as well as providing the [[CSS|cascading style sheet]] for your site. Both the [[Front-end]] (Site) and the [[Back-end]] (Administrator) of your site have templates.&lt;br /&gt;
&lt;br /&gt;
When Joomla! is installed several templates are automatically included. You can find many more templates at other websites. Some are available without charge under various licenses, and some are for sale. In addition, there are many designers available who can make custom templates. You can also [[Joomla! 1.5 Template Tutorials Project|make your own template]].&lt;br /&gt;
&lt;br /&gt;
Templates are managed with the [[Template Manager]], which is located on the site menu on the Back-end of your site.&lt;br /&gt;
&lt;br /&gt;
The following may be helpful in understanding templates:&lt;br /&gt;
* http://help.joomla.org/content/view/474/153/&lt;br /&gt;
&lt;br /&gt;
===How do I install a new template?===&lt;br /&gt;
&#039;&#039;&#039;1.0&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In the [[Back-end]]  of the site, go to [[Installer]]s&amp;gt;&amp;gt;Templates-Site (or Templates-Administrator if you are installing an administrator template).&lt;br /&gt;
&lt;br /&gt;
Browse for the template zip file and click &#039;&#039;Upload File&#039;&#039; and &#039;&#039;Install&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can install from a directory.&lt;br /&gt;
&lt;br /&gt;
To make the new template the default template for your site, go to the [[Template Manager]] (Site&amp;gt;&amp;gt;Template Manager&amp;gt;&amp;gt;Site Templates).&lt;br /&gt;
You should see the name of your new template on the list of templates.&lt;br /&gt;
&lt;br /&gt;
Select it and click on the default icon if you want it to be the default icon for your site.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1.5&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In the [[Back-end]] of the site, go to [[Extension]]s&amp;gt;&amp;gt;Install/Uninstall.&lt;br /&gt;
&lt;br /&gt;
Browse for the template zip file and click Upload File and Install.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can install from a directory.&lt;br /&gt;
&lt;br /&gt;
To make the new template the default template for your site, select it and click the default icon (star).&lt;br /&gt;
&lt;br /&gt;
===How do I modify a template?===&lt;br /&gt;
Templates are just a series of xml, php, html and image files that are stored in the templates directory of your site.&lt;br /&gt;
You can edit these files or you can use the editing interface available in the [[Template Manager]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1.0&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In the [[Back-end]], select Site&amp;gt;&amp;gt;Template Manager&amp;gt;&amp;gt;Site Templates.&lt;br /&gt;
&lt;br /&gt;
Select the template you wish to modify.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1.5&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In the [[Back-end]], select Site&amp;gt;&amp;gt;[[Extension]]s&amp;gt;&amp;gt;Templates.&lt;br /&gt;
Select the template you wish to modify.&lt;br /&gt;
Click the edit icon.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;both&#039;&#039;&#039;&lt;br /&gt;
You are given the choice of editing &amp;quot;html&amp;quot; and &amp;quot;css.&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
[[CSS]] stands for cascading style sheets. This controls many elements of the look and feel of your site.&lt;br /&gt;
[[HTML]] is the file that controls where positions are defined and positioned. Other than that, it should be noted that, with a few exceptions, what is in the .css and what is in the HTML files largely depends on the approach of the tempate designer.&lt;br /&gt;
&lt;br /&gt;
One common change is to use your own graphic/image. Graphics are linked to in the HTML file. Simply change the reference to the image of your choice. Keep in mind that it if it is a different size than the original image this may change the appearance of the site in unexpected ways.&lt;br /&gt;
&lt;br /&gt;
===How do I assign a template to a specific page?===&lt;br /&gt;
&lt;br /&gt;
In Joomla! there is a default template, but you can assign other templates to specific &amp;quot;pages&amp;quot; that are defined by menu links.&lt;br /&gt;
&lt;br /&gt;
To assign a template to a page, you must first make sure that there is a direct menu link to the page.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1.0&#039;&#039;&#039;&lt;br /&gt;
* Go to Site&amp;gt;&amp;gt;[[Template Manager]]&amp;gt;&amp;gt;Site Templates&lt;br /&gt;
* Select the template you wish to assign.&lt;br /&gt;
* Click on the assign icon.&lt;br /&gt;
* On the right, there will be a list with all of the possible pages the template can be assigned to. Select one or more pages and save.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1.5&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Go to [[Extension]]s&amp;gt;&amp;gt;[[Template Manager]]&lt;br /&gt;
* Select the Template and click the edit icon (or click the template name)&lt;br /&gt;
* In the left column, change &amp;quot;None&amp;quot; to &amp;quot;Select from List.&amp;quot;&lt;br /&gt;
* Select the links you want to apply the template to.&lt;br /&gt;
* Save&lt;br /&gt;
&lt;br /&gt;
Note that you cannot assign the default template to individual pages.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Understanding&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The templating system uses the [[ItemID]] to determine which template to show. ItemIDs are created when you create a menu link. This is why only menu items are shown in the list of pages to which you can assign templates.&lt;br /&gt;
&lt;br /&gt;
===What are the base Joomla! CSS styles?===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1.0&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Provided by Haaris&lt;br /&gt;
&lt;br /&gt;
 /**com_contact**/&lt;br /&gt;
  .componentheading&lt;br /&gt;
  .contentpane&lt;br /&gt;
  .contentdescription&lt;br /&gt;
  .sectiontableheader&lt;br /&gt;
  .category&lt;br /&gt;
  .small&lt;br /&gt;
  .contentpane&lt;br /&gt;
  .contentheading&lt;br /&gt;
  .contact_email&lt;br /&gt;
  .inputbox&lt;br /&gt;
  .button&lt;br /&gt;
&lt;br /&gt;
 /**com_content**/&lt;br /&gt;
  .componentheading&lt;br /&gt;
  .contentpane&lt;br /&gt;
  .contentdescription&lt;br /&gt;
  .inputbox&lt;br /&gt;
  .sectiontableheader&lt;br /&gt;
  .sectiontableentry1&lt;br /&gt;
  .sectiontableentry2&lt;br /&gt;
  .sectiontablefooter&lt;br /&gt;
  .blogsection&lt;br /&gt;
  .contentpaneopen&lt;br /&gt;
  .article_seperator&lt;br /&gt;
  .contentheading&lt;br /&gt;
  .contentpagetitle&lt;br /&gt;
  .buttonheading&lt;br /&gt;
  .small&lt;br /&gt;
  .createdate&lt;br /&gt;
  .modifydate&lt;br /&gt;
  .readon&lt;br /&gt;
  .pagenav_prev&lt;br /&gt;
  .pagenav_next&lt;br /&gt;
  .adminform&lt;br /&gt;
  .button&lt;br /&gt;
  .text_area&lt;br /&gt;
  .blog&lt;br /&gt;
  .blog_more&lt;br /&gt;
&lt;br /&gt;
 /**com_login**/&lt;br /&gt;
  .contentpane&lt;br /&gt;
  .componentheading&lt;br /&gt;
  .inputbox&lt;br /&gt;
  .button&lt;br /&gt;
&lt;br /&gt;
 /**com_newsfeeds**/&lt;br /&gt;
  .componentheading&lt;br /&gt;
  .contentpane&lt;br /&gt;
  .contentdescription&lt;br /&gt;
  .sectiontableheader&lt;br /&gt;
  .category&lt;br /&gt;
  .small&lt;br /&gt;
  .contentheading&lt;br /&gt;
&lt;br /&gt;
 /**com_poll**/&lt;br /&gt;
  .componentheading&lt;br /&gt;
  .contentpane&lt;br /&gt;
  .pollstableborder&lt;br /&gt;
  .sectiontableheader&lt;br /&gt;
  .smalldark&lt;br /&gt;
  .button&lt;br /&gt;
  .inputbox&lt;br /&gt;
&lt;br /&gt;
 /**com_registration**/&lt;br /&gt;
  .componentheading&lt;br /&gt;
  .contentpane&lt;br /&gt;
  .inputbox&lt;br /&gt;
  .button&lt;br /&gt;
&lt;br /&gt;
 /**com_search**/&lt;br /&gt;
  .componentheading&lt;br /&gt;
  .contentpaneopen&lt;br /&gt;
  .inputbox&lt;br /&gt;
  .button&lt;br /&gt;
  .searchintro&lt;br /&gt;
  .small&lt;br /&gt;
  .highlight&lt;br /&gt;
&lt;br /&gt;
 /**com_user**/&lt;br /&gt;
  .componentheading&lt;br /&gt;
  .inputbox&lt;br /&gt;
  .button&lt;br /&gt;
  .row1&lt;br /&gt;
  .row2&lt;br /&gt;
&lt;br /&gt;
 /**com_weblinks**/&lt;br /&gt;
  .componentheading&lt;br /&gt;
  .contentpane&lt;br /&gt;
  .contentdescription&lt;br /&gt;
  .sectiontableheader&lt;br /&gt;
  .tabclass1&lt;br /&gt;
  .tabclass2&lt;br /&gt;
  .small&lt;br /&gt;
  .category&lt;br /&gt;
  .inputbox&lt;br /&gt;
&lt;br /&gt;
 /**com_wrapper**/&lt;br /&gt;
  .contentpane&lt;br /&gt;
  .componentheading&lt;br /&gt;
  .wrapper&lt;br /&gt;
&lt;br /&gt;
 /**includes/frontend**/&lt;br /&gt;
  .moduletable&lt;br /&gt;
  .newsfeed&lt;br /&gt;
  .module&lt;br /&gt;
  .message&lt;br /&gt;
&lt;br /&gt;
 /**includes\HTML_toolbar  .php**/&lt;br /&gt;
  .toolbar&lt;br /&gt;
&lt;br /&gt;
 /**includes\joomla  .php**/&lt;br /&gt;
  .profiler&lt;br /&gt;
  .item&lt;br /&gt;
  .small&lt;br /&gt;
  .back_button&lt;br /&gt;
  .buttonheading&lt;br /&gt;
  .tab-page&lt;br /&gt;
  .tab&lt;br /&gt;
  .inputbox&lt;br /&gt;
&lt;br /&gt;
 /**includes\joomla  .xml  .php**/&lt;br /&gt;
  .paramlist&lt;br /&gt;
  .editlinktip&lt;br /&gt;
  .text_area&lt;br /&gt;
  .inputbox&lt;br /&gt;
&lt;br /&gt;
 /**includes\pageNavigation  .php**/&lt;br /&gt;
  .inputbox&lt;br /&gt;
  .pagenav&lt;br /&gt;
&lt;br /&gt;
 /**includes\pathway  .php**/&lt;br /&gt;
  .pathway&lt;br /&gt;
&lt;br /&gt;
 /**includes\js\dtree\dtree  .js**/&lt;br /&gt;
  .dtree&lt;br /&gt;
  .dTreeNode&lt;br /&gt;
  .node&lt;br /&gt;
  .clip&lt;br /&gt;
&lt;br /&gt;
 /**includes\patTemplate\tmpl\forms  .html**/&lt;br /&gt;
  .message&lt;br /&gt;
  .tooltip&lt;br /&gt;
  .tab-page&lt;br /&gt;
  .tab&lt;br /&gt;
  .expander&lt;br /&gt;
&lt;br /&gt;
 /**mambots\content\mosimage  .php**/&lt;br /&gt;
  .mosimage_caption&lt;br /&gt;
  .mosimage&lt;br /&gt;
&lt;br /&gt;
 /**mambots\content\mospaging  .php**/&lt;br /&gt;
  .pagenavcounter&lt;br /&gt;
  .pagenavbar&lt;br /&gt;
  .contenttoc&lt;br /&gt;
  .toclink&lt;br /&gt;
&lt;br /&gt;
 /**mambots\content\mosvote  .php**/&lt;br /&gt;
  .content_rating&lt;br /&gt;
  .content_vote&lt;br /&gt;
  .button&lt;br /&gt;
&lt;br /&gt;
 /**modules\mod_latestnews  .php**/&lt;br /&gt;
  .latestnews&lt;br /&gt;
&lt;br /&gt;
 /**modules\mod_login  .php**/&lt;br /&gt;
  .button&lt;br /&gt;
  .inputbox&lt;br /&gt;
&lt;br /&gt;
 /**modules\mod_mostread  .php**/&lt;br /&gt;
  .mostread&lt;br /&gt;
&lt;br /&gt;
 /**modules\mod_mostread  .php**/&lt;br /&gt;
  .poll&lt;br /&gt;
  .pollstableborder&lt;br /&gt;
  .button&lt;br /&gt;
&lt;br /&gt;
 /**modules\mod_mostread  .php**/&lt;br /&gt;
  .syndicate&lt;br /&gt;
  .syndicate_text&lt;br /&gt;
&lt;br /&gt;
 /**modules\mod_search  .php**/&lt;br /&gt;
  .inputbox&lt;br /&gt;
  .button&lt;br /&gt;
  .search&lt;br /&gt;
&lt;br /&gt;
Provided by Compass:&lt;br /&gt;
&lt;br /&gt;
 #active_menu&lt;br /&gt;
 #blockrandom&lt;br /&gt;
 #contact_email_copy&lt;br /&gt;
 #contact_text&lt;br /&gt;
 #emailForm&lt;br /&gt;
 #mod_login_password&lt;br /&gt;
 #mod_login_remember&lt;br /&gt;
 #mod_login_username&lt;br /&gt;
 #poll&lt;br /&gt;
 #search_ordering&lt;br /&gt;
 #search_searchword&lt;br /&gt;
 #searchphraseall&lt;br /&gt;
 #searchphraseany&lt;br /&gt;
 #searchphraseexact&lt;br /&gt;
 #voteid1, #voteid2&lt;br /&gt;
  .adminform&lt;br /&gt;
  .article_seperator&lt;br /&gt;
  .back_button&lt;br /&gt;
  .blog&lt;br /&gt;
  .blog_more&lt;br /&gt;
  .blogsection&lt;br /&gt;
  .button&lt;br /&gt;
  .buttonheading&lt;br /&gt;
  .category&lt;br /&gt;
  .clr&lt;br /&gt;
  .componentheading&lt;br /&gt;
  .contact_email&lt;br /&gt;
  .content_rating&lt;br /&gt;
  .content_vote&lt;br /&gt;
  .contentdescription&lt;br /&gt;
  .contentheading&lt;br /&gt;
  .contentpagetitle&lt;br /&gt;
  .contentpane&lt;br /&gt;
  .contentpaneopen&lt;br /&gt;
  .contenttoc&lt;br /&gt;
  .createdate&lt;br /&gt;
  .fase4rdf&lt;br /&gt;
  .footer&lt;br /&gt;
  .frontpageheader&lt;br /&gt;
  .inputbox&lt;br /&gt;
  .latestnews&lt;br /&gt;
  .mainlevel&lt;br /&gt;
  .message&lt;br /&gt;
  .modifydate&lt;br /&gt;
  .module&lt;br /&gt;
  .moduletable&lt;br /&gt;
  .mostread&lt;br /&gt;
  .newsfeed&lt;br /&gt;
  .newsfeeddate&lt;br /&gt;
  .newsfeedheading&lt;br /&gt;
  .pagenav&lt;br /&gt;
  .pagenav_next&lt;br /&gt;
  .pagenav_prev&lt;br /&gt;
  .pagenavbar&lt;br /&gt;
  .pagenavcounter&lt;br /&gt;
  .pathway&lt;br /&gt;
  .polls&lt;br /&gt;
  .pollsborder&lt;br /&gt;
  .pollstableborder&lt;br /&gt;
  .readon&lt;br /&gt;
  .readon:hover&lt;br /&gt;
  .search&lt;br /&gt;
  .searchintro&lt;br /&gt;
  .sectionentry1&lt;br /&gt;
  .sectionentry2&lt;br /&gt;
  .sectionheader&lt;br /&gt;
  .sitetitle&lt;br /&gt;
  .small&lt;br /&gt;
  .smalldark&lt;br /&gt;
  .sublevel&lt;br /&gt;
  .syndicate&lt;br /&gt;
  .syndicate_text&lt;br /&gt;
  .text_area&lt;br /&gt;
  .toclink&lt;br /&gt;
  .weblinks&lt;br /&gt;
  .wrapper&lt;br /&gt;
&lt;br /&gt;
===What are module switches?  (or -1 -2 and -3) ===&lt;br /&gt;
This is how you apply the switches:&lt;br /&gt;
&lt;br /&gt;
; &amp;lt;nowiki&amp;gt;switch: -1&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: Strips all surrounding code from the module.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;?php mosLoadModules ( &#039;user1&#039;, -1 ); ?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The outputted html code looks like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;user1_inner&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;ul class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=3&amp;amp;Itemid=9&amp;quot;    &lt;br /&gt;
  class=&amp;quot;latestnews&amp;quot;&amp;gt;Newsflash 2&lt;br /&gt;
  &amp;lt;/a&amp;gt;&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=4&amp;amp;Itemid=9&amp;quot;  &lt;br /&gt;
  class=&amp;quot;latestnews&amp;quot;&amp;gt;Newsflash 3&lt;br /&gt;
  &amp;lt;/a&amp;gt;&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=2&amp;amp;Itemid=9&amp;quot; &lt;br /&gt;
  class=&amp;quot;latestnews&amp;quot;&amp;gt;Newsflash 1&lt;br /&gt;
  &amp;lt;/a&amp;gt;&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=9&amp;amp;Itemid=2&amp;quot; &lt;br /&gt;
  class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
  Example News Item 4&lt;br /&gt;
  &amp;lt;/a&amp;gt;&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=7&amp;amp;Itemid=2&amp;quot; &lt;br /&gt;
  class=&amp;quot;latestnews&amp;quot;&amp;gt;       &lt;br /&gt;
  Example News Item 2&lt;br /&gt;
  &amp;lt;/a&amp;gt;&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; &amp;lt;nowiki&amp;gt;switch: -2&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
: Puts the module&#039;s title in a h3, and wraps the entire thing in a&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;?php mosLoadModules ( &#039;user1&#039;, -2 ); ?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The outputted html code looks like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;div class=&amp;quot;moduletable&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;h3&amp;gt;Latest News&amp;lt;/h3&amp;gt;&lt;br /&gt;
 &amp;lt;ul class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=4&amp;amp;Itemid=9&amp;quot; &lt;br /&gt;
   class=&amp;quot;latestnews&amp;quot;&amp;gt;Newsflash 3&lt;br /&gt;
   &amp;lt;/a&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=2&amp;amp;Itemid=9&amp;quot; &lt;br /&gt;
   class=&amp;quot;latestnews&amp;quot;&amp;gt;Newsflash 1&lt;br /&gt;
   &amp;lt;/a&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=3&amp;amp;Itemid=9&amp;quot;  &lt;br /&gt;
   class=&amp;quot;latestnews&amp;quot;&amp;gt;Newsflash 2&lt;br /&gt;
   &amp;lt;/a&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=6&amp;amp;Itemid=2&amp;quot;&lt;br /&gt;
   class=&amp;quot;latestnews&amp;quot;&amp;gt;Example News Item 1&lt;br /&gt;
   &amp;lt;/a&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=9&amp;amp;Itemid=2&amp;quot; &lt;br /&gt;
   class=&amp;quot;latestnews&amp;quot;&amp;gt;Example News Item 4&lt;br /&gt;
   &amp;lt;/a&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
 &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;nowiki&amp;gt;switch: -3&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
:Puts the module&#039;s title in a h3, and ads several layers of divs that can be used to apply [[CSS]] techniques with [[Rounded corners|rounded corners]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;?php mosLoadModules ( &#039;user1&#039;, -3 ); ?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The outputted code looks like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;div class=&amp;quot;module&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;div&amp;gt;&lt;br /&gt;
 &amp;lt;div&amp;gt;&lt;br /&gt;
 &amp;lt;div&amp;gt;&lt;br /&gt;
 &amp;lt;h3&amp;gt;Latest News&amp;lt;/h3&amp;gt;&lt;br /&gt;
 &amp;lt;ul class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=4&amp;amp;Itemid=9&amp;quot;      &lt;br /&gt;
   class=&amp;quot;latestnews&amp;quot;&amp;gt;Newsflash 3&lt;br /&gt;
   &amp;lt;/a&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=2&amp;amp;Itemid=9&amp;quot; &lt;br /&gt;
   class=&amp;quot;latestnews&amp;quot;&amp;gt;Newsflash 1&lt;br /&gt;
   &amp;lt;/a&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=3&amp;amp;Itemid=9&amp;quot; &lt;br /&gt;
   class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
   Newsflash 2 &amp;lt;/a&amp;gt; &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=6&amp;amp;Itemid=2&amp;quot; &lt;br /&gt;
   class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
   Example News Item 1&lt;br /&gt;
   &amp;lt;/a&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=9&amp;amp;Itemid=2&amp;quot; &lt;br /&gt;
   class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
   Example News Item 4&lt;br /&gt;
   &amp;lt;/a&amp;gt;&lt;br /&gt;
   &amp;lt;/li&amp;gt;&lt;br /&gt;
 &amp;lt;/ul&amp;gt;&lt;br /&gt;
 &amp;lt;/div&amp;gt;&lt;br /&gt;
 &amp;lt;/div&amp;gt;&lt;br /&gt;
 &amp;lt;/div&amp;gt;&lt;br /&gt;
 &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If there is no switch at all:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;?php mosLoadModules ( &#039;user1&#039;); ?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The outputted code looks like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;table class=&amp;quot;moduletable&amp;quot; border=&amp;quot;0&amp;quot; cellpadding=&amp;quot;0&amp;quot; cellspacing=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;tbody&amp;gt;&lt;br /&gt;
     &amp;lt;tr&amp;gt;&lt;br /&gt;
       &amp;lt;th valign=&amp;quot;top&amp;quot;&amp;gt;&lt;br /&gt;
      Latest News&lt;br /&gt;
       &amp;lt;/th&amp;gt;&lt;br /&gt;
     &amp;lt;/tr&amp;gt;&lt;br /&gt;
     &amp;lt;tr&amp;gt;&lt;br /&gt;
       &amp;lt;td&amp;gt;&lt;br /&gt;
       &amp;lt;ul class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=4&amp;amp;Itemid=9&amp;quot;&lt;br /&gt;
         class=&amp;quot;latestnews&amp;quot;&amp;gt;Newsflash 3&lt;br /&gt;
         &amp;lt;/a&amp;gt;&lt;br /&gt;
         &amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=2&amp;amp;Itemid=9&amp;quot;&lt;br /&gt;
         class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
         Newsflash 1 &lt;br /&gt;
         &amp;lt;/a&amp;gt; &lt;br /&gt;
         &amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=3&amp;amp;Itemid=9&amp;quot;&lt;br /&gt;
         class=&amp;quot;latestnews&amp;quot;&amp;gt;Newsflash 2&lt;br /&gt;
         &amp;lt;/a&amp;gt;&lt;br /&gt;
         &amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=6&amp;amp;Itemid=2&amp;quot;&lt;br /&gt;
         class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
         Example News Item 1&lt;br /&gt;
         &amp;lt;/a&amp;gt;&lt;br /&gt;
         &amp;lt;/li&amp;gt;&lt;br /&gt;
         &amp;lt;li class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;a href=&amp;quot;http://localhost/projects/1112rc2/index.php?option=com_content&amp;amp;task=view&amp;amp;id=9&amp;amp;Itemid=2&amp;quot;&lt;br /&gt;
         class=&amp;quot;latestnews&amp;quot;&amp;gt;&lt;br /&gt;
         Example News Item 4&lt;br /&gt;
         &amp;lt;/a&amp;gt;&lt;br /&gt;
         &amp;lt;/li&amp;gt;&lt;br /&gt;
       &amp;lt;/ul&amp;gt;&lt;br /&gt;
       &amp;lt;/td&amp;gt;&lt;br /&gt;
     &amp;lt;/tr&amp;gt;&lt;br /&gt;
   &amp;lt;/tbody&amp;gt;&lt;br /&gt;
 &amp;lt;/table&amp;gt;&lt;br /&gt;
 &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Joomla! 1.5 each switch has a style associated with it.&lt;br /&gt;
&lt;br /&gt;
		switch -3:    $style = &#039;rounded&#039;;&lt;br /&gt;
                switch -2:  $style = &#039;xhtml&lt;br /&gt;
                switch  -1:  $stylle = &#039;raw&#039;;&lt;br /&gt;
		switch   0 :$style = &#039;table&#039;;&lt;br /&gt;
&lt;br /&gt;
===How do I add a position to a template?===&lt;br /&gt;
To create a &amp;quot;new&amp;quot; position chose one of the names from the list of positions shown in&lt;br /&gt;
Site&amp;gt;[[Template Manager]]&amp;gt;Module Positions&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1.0&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In your template add&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;?php mosLoadModules (&#039;position_name&#039;); ?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will want to surround it with approprate html so that it appears where you want it to and with the formatting you want.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1.5&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===How do I change the image(s) in my template?===&lt;br /&gt;
One common [[Template|template]] change is to use your own graphic/image. Simple graphics (not [[Banner|banners]]) are linked in the [[HTML]] file. Simply change the reference to the image of your choice in the HTML file of your template.  Do this by, in the [[Back-end|adminsitrative interface]], going to Site&amp;gt;&amp;gt;[[Template Manager]] and then selecting your template. Click the icon for html.&lt;br /&gt;
&lt;br /&gt;
Keep in mind that if it is a different size than the original image this may change the appearance of the site in unexpected ways.&lt;br /&gt;
&lt;br /&gt;
The images for a given template are generally located in this folder:&lt;br /&gt;
 /templates/&#039;&#039;templatename&#039;&#039;/images &lt;br /&gt;
(where you substitute the name of the template you are using.)&lt;br /&gt;
&lt;br /&gt;
===How do I collapse an empty position in a template?===&lt;br /&gt;
Very often the question is asked on how to collapse a position in any template. Note collapse here means &amp;quot;not show&amp;quot; if no modules are published to these columns.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1.0&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Here is a method on how to do this as an example with the tremendous popular [[rhuk_solarflare]] template:&lt;br /&gt;
&lt;br /&gt;
open &amp;lt;tt&amp;gt;../templates/rhuk_solarflare_ii/index.php&amp;lt;/tt&amp;gt; and find and replace this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;left_outer&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div id=&amp;quot;left_inner&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;?php mosLoadModules ( &#039;left&#039;, -2 ); ?&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;content_outer&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
with this :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;?php&lt;br /&gt;
      if ( !(mosCountModules( &#039;left&#039; )) ) {&lt;br /&gt;
    ?&amp;gt;&lt;br /&gt;
     &amp;lt;div id=&amp;quot;content_outer2&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;?&lt;br /&gt;
     }&lt;br /&gt;
     else {&lt;br /&gt;
     ?&amp;gt;&lt;br /&gt;
     &amp;lt;div id=&amp;quot;left_outer&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div id=&amp;quot;left_inner&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;?php mosLoadModules ( &#039;left&#039;, -2 ); ?&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
     &amp;lt;/div&amp;gt;&lt;br /&gt;
     &amp;lt;div id=&amp;quot;content_outer&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;?&lt;br /&gt;
     }&lt;br /&gt;
    ?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
and save the file.&lt;br /&gt;
&lt;br /&gt;
Then open &amp;lt;tt&amp;gt;../templates/rhuk_solarflare_ii/css/template_css.css&amp;lt;/tt&amp;gt; file and add:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
 #content_outer2 {&lt;br /&gt;
    padding: 0px;&lt;br /&gt;
    margin-top: 0px;&lt;br /&gt;
    margin-left: 0px;&lt;br /&gt;
    /** border: 1px solid #cccccc; **/&lt;br /&gt;
    float: left;&lt;br /&gt;
    width: 800px;&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and your left column now will collapse when you don&#039;t publish anything to it!&lt;br /&gt;
&lt;br /&gt;
This method you can multiply to any template if you try to follow the logic of the code!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1.5&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===CSS Text/Font Resizing (A+ A-) on Joomla Template===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1.0&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I recognize that there are some of you who are sort of scratching your heads wondering how to get from where your site is now to where joomla.org&#039;s is. So for those of you wanting it laid out all the way, here&#039;s a more detailed instruction set that summarizes and extends what has already been said through the course of this thread:&lt;br /&gt;
&lt;br /&gt;
Step 1 - download joomla.org&#039;s font style switcher file ( http://forum.joomla.org/Themes/joomla/md_stylechanger.js )&lt;br /&gt;
Step 2 - put that file somewhere in the folder of the template you are using&lt;br /&gt;
Step 3 - put A+, A-, and Reset images in your template&#039;s image folder&lt;br /&gt;
Step 4 - paste the following code snippet somewhere in your template&#039;s index.php file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- PLEASE! avoid extra-wide lines that may cause scrollbars in common screen-sizes &lt;br /&gt;
     and wrap ~ 80 chars / attribute level for better readability --&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php &lt;br /&gt;
// shortcut of template URL used in src attributes&lt;br /&gt;
$template_url = $mosConfig_live_site .&#039;/templates/&#039;. $mainframe-&amp;gt;getTemplate(); &lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; language=&amp;quot;javascript&amp;quot; &lt;br /&gt;
       src=&amp;quot;&amp;lt;?php echo $template_url; ?&amp;gt;/____1____&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;a href=&amp;quot;index.php&amp;quot; title=&amp;quot;Increase size&amp;quot; onclick=&amp;quot;changeFontSize(1);return false;&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;img src=&amp;quot;&amp;lt;?php echo $template_url; ?&amp;gt;/images/____2____&amp;quot; alt=&amp;quot;&amp;quot; border=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;a href=&amp;quot;index.php&amp;quot; title=&amp;quot;Decrease size&amp;quot; onclick=&amp;quot;changeFontSize(-1);return false;&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;img src=&amp;quot;&amp;lt;?php echo $template_url; ?&amp;gt;/images/____3____&amp;quot; alt=&amp;quot;&amp;quot; border=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;a href=&amp;quot;index.php&amp;quot; title=&amp;quot;Revert styles to default&amp;quot; onclick=&amp;quot;revertStyles(); return false;&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;img src=&amp;quot;&amp;lt;?php echo $template_url; ?&amp;gt;/images/____4____&amp;quot; alt=&amp;quot;&amp;quot; border=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Step 5: Do all of the following:&lt;br /&gt;
&lt;br /&gt;
* Replace ____1____ with the location in your template folder where you saved the .js file&lt;br /&gt;
* Replace ____2____ with the name of your A+ image&lt;br /&gt;
* Replace ____3____ with the name of your A- image&lt;br /&gt;
* Replace ____4____ with the name of your Reset image&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Step 6: Do one of the following:&lt;br /&gt;
&lt;br /&gt;
* Bask in the awesomeness that is session font resizing&lt;br /&gt;
* Start figuring out why the buttons do nothing (either because your site doesn&#039;t use style classes, or because I messed up somewhere)&lt;br /&gt;
&lt;br /&gt;
===Can I remove the &amp;quot;Powered by Joomla!&amp;quot; message?===&lt;br /&gt;
&lt;br /&gt;
Yes. You may remove that message, which is in &amp;lt;tt&amp;gt;footer.php&amp;lt;/tt&amp;gt;. You may however &#039;&#039;&#039;not&#039;&#039;&#039; remove copyright and license information from the source code.&lt;br /&gt;
&lt;br /&gt;
===How do I make it so my modules are laid out horizontally?===&lt;br /&gt;
&lt;br /&gt;
See [[Administration_FAQs#How_do_I_control_whether_modules_are_vertically_or_horizontally_arranged.3F | How do I control whether modules are vertically or horizontally arranged?]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=8526</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=8526"/>
		<updated>2008-06-24T22:01:27Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Writing Unit Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{cookiejar}}&lt;br /&gt;
== News and Updates ==&lt;br /&gt;
2008 06 24: Update to reflect move of PHPUnit code from branch to trunk (former trunk now in /branches/old_simpletest).&lt;br /&gt;
&lt;br /&gt;
2008 06 22: Add information on limiting tests by version.&lt;br /&gt;
&lt;br /&gt;
2008 06 21: Added --class-exclude, --sequence-exclude, and --test-exclude options.&lt;br /&gt;
&lt;br /&gt;
2008 06 21: PHPUnit has been updated to version 3.2.21 with SVN rev 10436. Please update.&lt;br /&gt;
&lt;br /&gt;
== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For a good general discussion of unit testing, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with Selenium, a browser based test automation tool.&lt;br /&gt;
&lt;br /&gt;
==== Test Objects ====&lt;br /&gt;
The purpose of unit tests is to isolate a module of code. A test that tests only one thing provides better information than a test that involves several object interactions. But how do we isolate an object from its dependencies? By writing stub classes. [http://xunitpatterns.com/Mocks,%20Fakes,%20Stubs%20and%20Dummies.html xUnit Patterns] defines a the hierarchy of dummy classes, ranging from simple to complex:&lt;br /&gt;
* Dummy - Defines attributes and methods of a dummy class (not particularly useful in PHP).&lt;br /&gt;
* Fake - Provides canned responses to method calls and fixed attribute values. Good for speed.&lt;br /&gt;
* Stub - Allows the test to define responses to method calls (return values, exceptions) to simulate the dependent object.&lt;br /&gt;
* Spy - A Fake or Stub that records method calls and parameters for later analysis.&lt;br /&gt;
* Mock - A Fake or Stub with a set of expectations -- method calls and parameters -- that are automatically verified for correctness.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests.&lt;br /&gt;
&lt;br /&gt;
For an overview of unit testing status in Joomla visit the [[Unit_Testing_Status]] page.&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
The PHPUnit tests are available from &#039;&#039;&#039;/testing/trunk&#039;&#039;&#039;. Some new tests have been added, any remaining tests from the SimpleTest days are completely broken. See /testing/branches/old-simpletest if you need to run something from that suite.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== The Unit Test Team ====&lt;br /&gt;
If you can commit to the Joomla code base, then you should consider yourself part of the unit test team!&lt;br /&gt;
&lt;br /&gt;
Writing tests concurrently with code (or even before) is a good way to not only save development time, but a great tool for defending against regressions. Writing tests early in the development cycle also helps identify and resolve design issues sooner, which reduces refactoring.&lt;br /&gt;
&lt;br /&gt;
If you want to get started on unit testing, get in touch with Alan Langford (instance) or Ray Tsai (mihu). Either of us will be happy to help out.&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing dummy classes that emulate the code unit&#039;s environment. These dummy objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour. See [[Unit_Testing_Mock_Objects|Mock Objects in Joomla]] for a detailed example.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]], [[Unit_Testing_--_UI_Example|UI Example]].&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--class-exclude &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-exclude /JDate.*/ Skips tests that have a class part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--class-filter &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--debug&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--sequence-exclude &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Skips tests that have a sequence part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--sequence-filter &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--test-exclude &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Skips tests that have a test part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--test-filter &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;br /&gt;
&lt;br /&gt;
== How to Get it Running ==&lt;br /&gt;
&lt;br /&gt;
Before you start make sure you have installed PHPUnit and of course PHP (5!) properly...&lt;br /&gt;
&lt;br /&gt;
To get the unit tests to run on your Joomla! installation, perform the following steps:&lt;br /&gt;
* Create an instance of your Joomla! installation&lt;br /&gt;
* In the root checkout (or export) the latest version of the unit test code from SVN &#039;&#039;&amp;quot;/testing/trunk&amp;quot;&#039;&#039; to your installation base. This will create a &#039;&#039;&amp;quot;/unittest&amp;quot;&#039;&#039; sub-folder under your joomla installation.&lt;br /&gt;
* Create a &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file. You can copy a the file from &#039;&#039;&amp;quot;TestConfiguration-dist.php&amp;quot;&#039;&#039; that is part of the package you just have checked out.&lt;br /&gt;
* If you want to run a subset of the commands, change to the directory that contains those tests.&lt;br /&gt;
* Run the unit test from the command using the following command:&lt;br /&gt;
&lt;br /&gt;
 php runtests.php&lt;br /&gt;
&lt;br /&gt;
The unit test will the run, and the results are rendered.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
The provided configurations should work out of the box. We have seen problems with it (currently the cause is unknown). If you get an error like blow, the  solution is pretty easy.&lt;br /&gt;
&lt;br /&gt;
 file=/var/www/unittest/runtests.php&lt;br /&gt;
 posn=17&lt;br /&gt;
 base=runtests.php&lt;br /&gt;
 /var/www&lt;br /&gt;
  JPATH_BASE does not point to a valid Joomla! installation:&lt;br /&gt;
 JPATH_BASE = /var/www&lt;br /&gt;
  Please modify your copy of &amp;quot;TestConfiguration.php&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Modify the &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file and change the definition of the JPATH_BASE so it points to the path of you Joomla! installation, in the example below the Joomla! installation is installed at &amp;quot;&#039;&#039;/var/www/update&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 define(&#039;JPATH_BASE&#039;, &#039;/var/www/update&#039;);&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&#039;&#039;&#039;Why can&#039;t I use &amp;quot;phpunit &#039;&#039;testname.php&#039;&#039;&amp;quot; to run my tests?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The test facility has to do some work to be able to load the &amp;quot;Joomla!&amp;quot; framework and to be able to inject mock classes. It&#039;s difficult to do this from the PHPUnit test runner, so we built our own. Also, the Joomla test runner has specific options designed to make it easy to select specific tests. Over time we will add more functionality to the test runner so it has many of the capabilities of the phpunit command.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[http://www.phpunit.de/pocket_guide/3.2/en/index.html PHPUnit Pocket Guide]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=8525</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=8525"/>
		<updated>2008-06-24T22:01:05Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Writing Unit Tests */ add ink to UI exampe&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{cookiejar}}&lt;br /&gt;
== News and Updates ==&lt;br /&gt;
2008 06 24: Update to reflect move of PHPUnit code from branch to trunk (former trunk now in /branches/old_simpletest).&lt;br /&gt;
&lt;br /&gt;
2008 06 22: Add information on limiting tests by version.&lt;br /&gt;
&lt;br /&gt;
2008 06 21: Added --class-exclude, --sequence-exclude, and --test-exclude options.&lt;br /&gt;
&lt;br /&gt;
2008 06 21: PHPUnit has been updated to version 3.2.21 with SVN rev 10436. Please update.&lt;br /&gt;
&lt;br /&gt;
== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For a good general discussion of unit testing, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with Selenium, a browser based test automation tool.&lt;br /&gt;
&lt;br /&gt;
==== Test Objects ====&lt;br /&gt;
The purpose of unit tests is to isolate a module of code. A test that tests only one thing provides better information than a test that involves several object interactions. But how do we isolate an object from its dependencies? By writing stub classes. [http://xunitpatterns.com/Mocks,%20Fakes,%20Stubs%20and%20Dummies.html xUnit Patterns] defines a the hierarchy of dummy classes, ranging from simple to complex:&lt;br /&gt;
* Dummy - Defines attributes and methods of a dummy class (not particularly useful in PHP).&lt;br /&gt;
* Fake - Provides canned responses to method calls and fixed attribute values. Good for speed.&lt;br /&gt;
* Stub - Allows the test to define responses to method calls (return values, exceptions) to simulate the dependent object.&lt;br /&gt;
* Spy - A Fake or Stub that records method calls and parameters for later analysis.&lt;br /&gt;
* Mock - A Fake or Stub with a set of expectations -- method calls and parameters -- that are automatically verified for correctness.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests.&lt;br /&gt;
&lt;br /&gt;
For an overview of unit testing status in Joomla visit the [[Unit_Testing_Status]] page.&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
The PHPUnit tests are available from &#039;&#039;&#039;/testing/trunk&#039;&#039;&#039;. Some new tests have been added, any remaining tests from the SimpleTest days are completely broken. See /testing/branches/old-simpletest if you need to run something from that suite.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== The Unit Test Team ====&lt;br /&gt;
If you can commit to the Joomla code base, then you should consider yourself part of the unit test team!&lt;br /&gt;
&lt;br /&gt;
Writing tests concurrently with code (or even before) is a good way to not only save development time, but a great tool for defending against regressions. Writing tests early in the development cycle also helps identify and resolve design issues sooner, which reduces refactoring.&lt;br /&gt;
&lt;br /&gt;
If you want to get started on unit testing, get in touch with Alan Langford (instance) or Ray Tsai (mihu). Either of us will be happy to help out.&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing dummy classes that emulate the code unit&#039;s environment. These dummy objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour. See [[Unit_Testing_Mock_Objects|Mock Objects in Joomla]] for a detailed example.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]]., [[Unit_Testing_--_UI_Example|UI Example]]&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--class-exclude &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-exclude /JDate.*/ Skips tests that have a class part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--class-filter &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--debug&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--sequence-exclude &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Skips tests that have a sequence part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--sequence-filter &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--test-exclude &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Skips tests that have a test part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--test-filter &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;br /&gt;
&lt;br /&gt;
== How to Get it Running ==&lt;br /&gt;
&lt;br /&gt;
Before you start make sure you have installed PHPUnit and of course PHP (5!) properly...&lt;br /&gt;
&lt;br /&gt;
To get the unit tests to run on your Joomla! installation, perform the following steps:&lt;br /&gt;
* Create an instance of your Joomla! installation&lt;br /&gt;
* In the root checkout (or export) the latest version of the unit test code from SVN &#039;&#039;&amp;quot;/testing/trunk&amp;quot;&#039;&#039; to your installation base. This will create a &#039;&#039;&amp;quot;/unittest&amp;quot;&#039;&#039; sub-folder under your joomla installation.&lt;br /&gt;
* Create a &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file. You can copy a the file from &#039;&#039;&amp;quot;TestConfiguration-dist.php&amp;quot;&#039;&#039; that is part of the package you just have checked out.&lt;br /&gt;
* If you want to run a subset of the commands, change to the directory that contains those tests.&lt;br /&gt;
* Run the unit test from the command using the following command:&lt;br /&gt;
&lt;br /&gt;
 php runtests.php&lt;br /&gt;
&lt;br /&gt;
The unit test will the run, and the results are rendered.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
The provided configurations should work out of the box. We have seen problems with it (currently the cause is unknown). If you get an error like blow, the  solution is pretty easy.&lt;br /&gt;
&lt;br /&gt;
 file=/var/www/unittest/runtests.php&lt;br /&gt;
 posn=17&lt;br /&gt;
 base=runtests.php&lt;br /&gt;
 /var/www&lt;br /&gt;
  JPATH_BASE does not point to a valid Joomla! installation:&lt;br /&gt;
 JPATH_BASE = /var/www&lt;br /&gt;
  Please modify your copy of &amp;quot;TestConfiguration.php&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Modify the &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file and change the definition of the JPATH_BASE so it points to the path of you Joomla! installation, in the example below the Joomla! installation is installed at &amp;quot;&#039;&#039;/var/www/update&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 define(&#039;JPATH_BASE&#039;, &#039;/var/www/update&#039;);&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&#039;&#039;&#039;Why can&#039;t I use &amp;quot;phpunit &#039;&#039;testname.php&#039;&#039;&amp;quot; to run my tests?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The test facility has to do some work to be able to load the &amp;quot;Joomla!&amp;quot; framework and to be able to inject mock classes. It&#039;s difficult to do this from the PHPUnit test runner, so we built our own. Also, the Joomla test runner has specific options designed to make it easy to select specific tests. Over time we will add more functionality to the test runner so it has many of the capabilities of the phpunit command.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[http://www.phpunit.de/pocket_guide/3.2/en/index.html PHPUnit Pocket Guide]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=8464</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=8464"/>
		<updated>2008-06-24T16:00:43Z</updated>

		<summary type="html">&lt;p&gt;Instance: Record move of PHPUnit branch into the trunk.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{cookiejar}}&lt;br /&gt;
== News and Updates ==&lt;br /&gt;
2008 06 24: Update to reflect move of PHPUnit code from branch to trunk (former trunk now in /branches/old_simpletest).&lt;br /&gt;
&lt;br /&gt;
2008 06 22: Add information on limiting tests by version.&lt;br /&gt;
&lt;br /&gt;
2008 06 21: Added --class-exclude, --sequence-exclude, and --test-exclude options.&lt;br /&gt;
&lt;br /&gt;
2008 06 21: PHPUnit has been updated to version 3.2.21 with SVN rev 10436. Please update.&lt;br /&gt;
&lt;br /&gt;
== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For a good general discussion of unit testing, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with Selenium, a browser based test automation tool.&lt;br /&gt;
&lt;br /&gt;
==== Test Objects ====&lt;br /&gt;
The purpose of unit tests is to isolate a module of code. A test that tests only one thing provides better information than a test that involves several object interactions. But how do we isolate an object from its dependencies? By writing stub classes. [http://xunitpatterns.com/Mocks,%20Fakes,%20Stubs%20and%20Dummies.html xUnit Patterns] defines a the hierarchy of dummy classes, ranging from simple to complex:&lt;br /&gt;
* Dummy - Defines attributes and methods of a dummy class (not particularly useful in PHP).&lt;br /&gt;
* Fake - Provides canned responses to method calls and fixed attribute values. Good for speed.&lt;br /&gt;
* Stub - Allows the test to define responses to method calls (return values, exceptions) to simulate the dependent object.&lt;br /&gt;
* Spy - A Fake or Stub that records method calls and parameters for later analysis.&lt;br /&gt;
* Mock - A Fake or Stub with a set of expectations -- method calls and parameters -- that are automatically verified for correctness.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests.&lt;br /&gt;
&lt;br /&gt;
For an overview of unit testing status in Joomla visit the [[Unit_Testing_Status]] page.&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
The PHPUnit tests are available from &#039;&#039;&#039;/testing/trunk&#039;&#039;&#039;. Some new tests have been added, any remaining tests from the SimpleTest days are completely broken. See /testing/branches/old-simpletest if you need to run something from that suite.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== The Unit Test Team ====&lt;br /&gt;
If you can commit to the Joomla code base, then you should consider yourself part of the unit test team!&lt;br /&gt;
&lt;br /&gt;
Writing tests concurrently with code (or even before) is a good way to not only save development time, but a great tool for defending against regressions. Writing tests early in the development cycle also helps identify and resolve design issues sooner, which reduces refactoring.&lt;br /&gt;
&lt;br /&gt;
If you want to get started on unit testing, get in touch with Alan Langford (instance) or Ray Tsai (mihu). Either of us will be happy to help out.&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing dummy classes that emulate the code unit&#039;s environment. These dummy objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour. See [[Unit_Testing_Mock_Objects|Mock Objects in Joomla]] for a detailed example.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]].&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--class-exclude &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-exclude /JDate.*/ Skips tests that have a class part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--class-filter &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--debug&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--sequence-exclude &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Skips tests that have a sequence part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--sequence-filter &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--test-exclude &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Skips tests that have a test part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--test-filter &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;br /&gt;
&lt;br /&gt;
== How to Get it Running ==&lt;br /&gt;
&lt;br /&gt;
Before you start make sure you have installed PHPUnit and of course PHP (5!) properly...&lt;br /&gt;
&lt;br /&gt;
To get the unit tests to run on your Joomla! installation, perform the following steps:&lt;br /&gt;
* Create an instance of your Joomla! installation&lt;br /&gt;
* In the root checkout (or export) the latest version of the unit test code from SVN &#039;&#039;&amp;quot;/testing/trunk&amp;quot;&#039;&#039; to your installation base. This will create a &#039;&#039;&amp;quot;/unittest&amp;quot;&#039;&#039; sub-folder under your joomla installation.&lt;br /&gt;
* Create a &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file. You can copy a the file from &#039;&#039;&amp;quot;TestConfiguration-dist.php&amp;quot;&#039;&#039; that is part of the package you just have checked out.&lt;br /&gt;
* If you want to run a subset of the commands, change to the directory that contains those tests.&lt;br /&gt;
* Run the unit test from the command using the following command:&lt;br /&gt;
&lt;br /&gt;
 php runtests.php&lt;br /&gt;
&lt;br /&gt;
The unit test will the run, and the results are rendered.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
The provided configurations should work out of the box. We have seen problems with it (currently the cause is unknown). If you get an error like blow, the  solution is pretty easy.&lt;br /&gt;
&lt;br /&gt;
 file=/var/www/unittest/runtests.php&lt;br /&gt;
 posn=17&lt;br /&gt;
 base=runtests.php&lt;br /&gt;
 /var/www&lt;br /&gt;
  JPATH_BASE does not point to a valid Joomla! installation:&lt;br /&gt;
 JPATH_BASE = /var/www&lt;br /&gt;
  Please modify your copy of &amp;quot;TestConfiguration.php&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Modify the &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file and change the definition of the JPATH_BASE so it points to the path of you Joomla! installation, in the example below the Joomla! installation is installed at &amp;quot;&#039;&#039;/var/www/update&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 define(&#039;JPATH_BASE&#039;, &#039;/var/www/update&#039;);&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&#039;&#039;&#039;Why can&#039;t I use &amp;quot;phpunit &#039;&#039;testname.php&#039;&#039;&amp;quot; to run my tests?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The test facility has to do some work to be able to load the &amp;quot;Joomla!&amp;quot; framework and to be able to inject mock classes. It&#039;s difficult to do this from the PHPUnit test runner, so we built our own. Also, the Joomla test runner has specific options designed to make it easy to select specific tests. Over time we will add more functionality to the test runner so it has many of the capabilities of the phpunit command.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[http://www.phpunit.de/pocket_guide/3.2/en/index.html PHPUnit Pocket Guide]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=8283</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=8283"/>
		<updated>2008-06-22T19:34:50Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* News and Updates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{cookiejar}}&lt;br /&gt;
== News and Updates ==&lt;br /&gt;
2008 06 22: Add information on limiting tests by version.&lt;br /&gt;
&lt;br /&gt;
2008 06 21: Added --class-exclude, --sequence-exclude, and --test-exclude options.&lt;br /&gt;
&lt;br /&gt;
2008 06 21: PHPUnit has been updated to version 3.2.21 with SVN rev 10436. Please update.&lt;br /&gt;
&lt;br /&gt;
== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For a good general discussion of unit testing, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with Selenium, a browser based test automation tool.&lt;br /&gt;
&lt;br /&gt;
==== Test Objects ====&lt;br /&gt;
The purpose of unit tests is to isolate a module of code. A test that tests only one thing provides better information than a test that involves several object interactions. But how do we isolate an object from its dependencies? By writing stub classes. [http://xunitpatterns.com/Mocks,%20Fakes,%20Stubs%20and%20Dummies.html xUnit Patterns] defines a the hierarchy of dummy classes, ranging from simple to complex:&lt;br /&gt;
* Dummy - Defines attributes and methods of a dummy class (not particularly useful in PHP).&lt;br /&gt;
* Fake - Provides canned responses to method calls and fixed attribute values. Good for speed.&lt;br /&gt;
* Stub - Allows the test to define responses to method calls (return values, exceptions) to simulate the dependent object.&lt;br /&gt;
* Spy - A Fake or Stub that records method calls and parameters for later analysis.&lt;br /&gt;
* Mock - A Fake or Stub with a set of expectations -- method calls and parameters -- that are automatically verified for correctness.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests.&lt;br /&gt;
&lt;br /&gt;
For an overview of unit testing status in Joomla visit the [[Unit_Testing_Status]] page.&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in &#039;&#039;&#039;/testing/branches/2007-12-17&#039;&#039;&#039;. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== The Unit Test Team ====&lt;br /&gt;
If you can commit to the Joomla code base, then you should consider yourself part of the unit test team!&lt;br /&gt;
&lt;br /&gt;
Writing tests concurrently with code (or even before) is a good way to not only save development time, but a great tool for defending against regressions. Writing tests early in the development cycle also helps identify and resolve design issues sooner, which reduces refactoring.&lt;br /&gt;
&lt;br /&gt;
If you want to get started on unit testing, get in touch with Alan Langford (instance) or Ray Tsai (mihu). Either of us will be happy to help out.&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing dummy classes that emulate the code unit&#039;s environment. These dummy objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour. See [[Unit_Testing_Mock_Objects|Mock Objects in Joomla]] for a detailed example.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]].&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--class-exclude &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-exclude /JDate.*/ Skips tests that have a class part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--class-filter &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--debug&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--sequence-exclude &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Skips tests that have a sequence part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--sequence-filter &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--test-exclude &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Skips tests that have a test part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--test-filter &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;br /&gt;
&lt;br /&gt;
== How to Get it Running ==&lt;br /&gt;
&lt;br /&gt;
Before you start make sure you have installed PHPUnit and of course PHP (5!) properly...&lt;br /&gt;
&lt;br /&gt;
To get the unit tests to run on your Joomla! installation, perform the following steps:&lt;br /&gt;
* Create an instance of your Joomla! installation&lt;br /&gt;
* In the root checkout (or export) the latest version of the unit test code from SVN &#039;&#039;&amp;quot;/testing/branches/2007-12-17&amp;quot;&#039;&#039; to your installation base. This will create a &#039;&#039;&amp;quot;/unittest&amp;quot;&#039;&#039; sub-folder under your joomla installation.&lt;br /&gt;
* Create a &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file. You can copy a the file from &#039;&#039;&amp;quot;TestConfiguration-dist.php&amp;quot;&#039;&#039; that is part of the package you just have checked out.&lt;br /&gt;
* If you want to run a subset of the commands, change to the directory that contains those tests.&lt;br /&gt;
* Run the unit test from the command using the following command:&lt;br /&gt;
&lt;br /&gt;
 php runtests.php&lt;br /&gt;
&lt;br /&gt;
The unit test will the run, and the results are rendered.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
The provided configurations should work out of the box. We have seen problems with it (currently the cause is unknown). If you get an error like blow, the  solution is pretty easy.&lt;br /&gt;
&lt;br /&gt;
 file=/var/www/unittest/runtests.php&lt;br /&gt;
 posn=17&lt;br /&gt;
 base=runtests.php&lt;br /&gt;
 /var/www&lt;br /&gt;
  JPATH_BASE does not point to a valid Joomla! installation:&lt;br /&gt;
 JPATH_BASE = /var/www&lt;br /&gt;
  Please modify your copy of &amp;quot;TestConfiguration.php&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Modify the &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file and change the definition of the JPATH_BASE so it points to the path of you Joomla! installation, in the example below the Joomla! installation is installed at &amp;quot;&#039;&#039;/var/www/update&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 define(&#039;JPATH_BASE&#039;, &#039;/var/www/update&#039;);&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&#039;&#039;&#039;Why can&#039;t I use &amp;quot;phpunit &#039;&#039;testname.php&#039;&#039;&amp;quot; to run my tests?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The test facility has to do some work to be able to load the &amp;quot;Joomla!&amp;quot; framework and to be able to inject mock classes. It&#039;s difficult to do this from the PHPUnit test runner, so we built our own. Also, the Joomla test runner has specific options designed to make it easy to select specific tests. Over time we will add more functionality to the test runner so it has many of the capabilities of the phpunit command.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[http://www.phpunit.de/pocket_guide/3.2/en/index.html PHPUnit Pocket Guide]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=8277</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=8277"/>
		<updated>2008-06-22T16:10:55Z</updated>

		<summary type="html">&lt;p&gt;Instance: Added a FAQ&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{cookiejar}}&lt;br /&gt;
== News and Updates ==&lt;br /&gt;
2008 06 21: Added --class-exclude, --sequence-exclude, and --test-exclude options.&lt;br /&gt;
&lt;br /&gt;
2008 06 21: PHPUnit has been updated to version 3.2.21 with SVN rev 10436. Please update.&lt;br /&gt;
&lt;br /&gt;
== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For a good general discussion of unit testing, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with Selenium, a browser based test automation tool.&lt;br /&gt;
&lt;br /&gt;
==== Test Objects ====&lt;br /&gt;
The purpose of unit tests is to isolate a module of code. A test that tests only one thing provides better information than a test that involves several object interactions. But how do we isolate an object from its dependencies? By writing stub classes. [http://xunitpatterns.com/Mocks,%20Fakes,%20Stubs%20and%20Dummies.html xUnit Patterns] defines a the hierarchy of dummy classes, ranging from simple to complex:&lt;br /&gt;
* Dummy - Defines attributes and methods of a dummy class (not particularly useful in PHP).&lt;br /&gt;
* Fake - Provides canned responses to method calls and fixed attribute values. Good for speed.&lt;br /&gt;
* Stub - Allows the test to define responses to method calls (return values, exceptions) to simulate the dependent object.&lt;br /&gt;
* Spy - A Fake or Stub that records method calls and parameters for later analysis.&lt;br /&gt;
* Mock - A Fake or Stub with a set of expectations -- method calls and parameters -- that are automatically verified for correctness.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests.&lt;br /&gt;
&lt;br /&gt;
For an overview of unit testing status in Joomla visit the [[Unit_Testing_Status]] page.&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in &#039;&#039;&#039;/testing/branches/2007-12-17&#039;&#039;&#039;. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== The Unit Test Team ====&lt;br /&gt;
If you can commit to the Joomla code base, then you should consider yourself part of the unit test team!&lt;br /&gt;
&lt;br /&gt;
Writing tests concurrently with code (or even before) is a good way to not only save development time, but a great tool for defending against regressions. Writing tests early in the development cycle also helps identify and resolve design issues sooner, which reduces refactoring.&lt;br /&gt;
&lt;br /&gt;
If you want to get started on unit testing, get in touch with Alan Langford (instance) or Ray Tsai (mihu). Either of us will be happy to help out.&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing dummy classes that emulate the code unit&#039;s environment. These dummy objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour. See [[Unit_Testing_Mock_Objects|Mock Objects in Joomla]] for a detailed example.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]].&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--class-exclude &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-exclude /JDate.*/ Skips tests that have a class part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--class-filter &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--debug&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--sequence-exclude &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Skips tests that have a sequence part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--sequence-filter &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--test-exclude &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Skips tests that have a test part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--test-filter &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;br /&gt;
&lt;br /&gt;
== How to Get it Running ==&lt;br /&gt;
&lt;br /&gt;
Before you start make sure you have installed PHPUnit and of course PHP (5!) properly...&lt;br /&gt;
&lt;br /&gt;
To get the unit tests to run on your Joomla! installation, perform the following steps:&lt;br /&gt;
* Create an instance of your Joomla! installation&lt;br /&gt;
* In the root checkout (or export) the latest version of the unit test code from SVN &#039;&#039;&amp;quot;/testing/branches/2007-12-17&amp;quot;&#039;&#039; to your installation base. This will create a &#039;&#039;&amp;quot;/unittest&amp;quot;&#039;&#039; sub-folder under your joomla installation.&lt;br /&gt;
* Create a &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file. You can copy a the file from &#039;&#039;&amp;quot;TestConfiguration-dist.php&amp;quot;&#039;&#039; that is part of the package you just have checked out.&lt;br /&gt;
* If you want to run a subset of the commands, change to the directory that contains those tests.&lt;br /&gt;
* Run the unit test from the command using the following command:&lt;br /&gt;
&lt;br /&gt;
 php runtests.php&lt;br /&gt;
&lt;br /&gt;
The unit test will the run, and the results are rendered.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
The provided configurations should work out of the box. We have seen problems with it (currently the cause is unknown). If you get an error like blow, the  solution is pretty easy.&lt;br /&gt;
&lt;br /&gt;
 file=/var/www/unittest/runtests.php&lt;br /&gt;
 posn=17&lt;br /&gt;
 base=runtests.php&lt;br /&gt;
 /var/www&lt;br /&gt;
  JPATH_BASE does not point to a valid Joomla! installation:&lt;br /&gt;
 JPATH_BASE = /var/www&lt;br /&gt;
  Please modify your copy of &amp;quot;TestConfiguration.php&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Modify the &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file and change the definition of the JPATH_BASE so it points to the path of you Joomla! installation, in the example below the Joomla! installation is installed at &amp;quot;&#039;&#039;/var/www/update&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 define(&#039;JPATH_BASE&#039;, &#039;/var/www/update&#039;);&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&#039;&#039;&#039;Why can&#039;t I use &amp;quot;phpunit &#039;&#039;testname.php&#039;&#039;&amp;quot; to run my tests?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The test facility has to do some work to be able to load the &amp;quot;Joomla!&amp;quot; framework and to be able to inject mock classes. It&#039;s difficult to do this from the PHPUnit test runner, so we built our own. Also, the Joomla test runner has specific options designed to make it easy to select specific tests. Over time we will add more functionality to the test runner so it has many of the capabilities of the phpunit command.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[http://www.phpunit.de/pocket_guide/3.2/en/index.html PHPUnit Pocket Guide]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=8088</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=8088"/>
		<updated>2008-06-21T14:05:09Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Running Unit Tests */ bold options to improve readability&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{cookiejar}}&lt;br /&gt;
== News and Updates ==&lt;br /&gt;
2008 06 21: Added --class-exclude, --sequence-exclude, and --test-exclude options.&lt;br /&gt;
&lt;br /&gt;
2008 06 21: PHPUnit has been updated to version 3.2.21 with SVN rev 10436. Please update.&lt;br /&gt;
&lt;br /&gt;
== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For a good general discussion of unit testing, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with Selenium, a browser based test automation tool.&lt;br /&gt;
&lt;br /&gt;
==== Test Objects ====&lt;br /&gt;
The purpose of unit tests is to isolate a module of code. A test that tests only one thing provides better information than a test that involves several object interactions. But how do we isolate an object from its dependencies? By writing stub classes. [http://xunitpatterns.com/Mocks,%20Fakes,%20Stubs%20and%20Dummies.html xUnit Patterns] defines a the hierarchy of dummy classes, ranging from simple to complex:&lt;br /&gt;
* Dummy - Defines attributes and methods of a dummy class (not particularly useful in PHP).&lt;br /&gt;
* Fake - Provides canned responses to method calls and fixed attribute values. Good for speed.&lt;br /&gt;
* Stub - Allows the test to define responses to method calls (return values, exceptions) to simulate the dependent object.&lt;br /&gt;
* Spy - A Fake or Stub that records method calls and parameters for later analysis.&lt;br /&gt;
* Mock - A Fake or Stub with a set of expectations -- method calls and parameters -- that are automatically verified for correctness.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests.&lt;br /&gt;
&lt;br /&gt;
For an overview of unit testing status in Joomla visit the [[Unit_Testing_Status]] page.&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in &#039;&#039;&#039;/testing/branches/2007-12-17&#039;&#039;&#039;. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== The Unit Test Team ====&lt;br /&gt;
If you can commit to the Joomla code base, then you should consider yourself part of the unit test team!&lt;br /&gt;
&lt;br /&gt;
Writing tests concurrently with code (or even before) is a good way to not only save development time, but a great tool for defending against regressions. Writing tests early in the development cycle also helps identify and resolve design issues sooner, which reduces refactoring.&lt;br /&gt;
&lt;br /&gt;
If you want to get started on unit testing, get in touch with Alan Langford (instance) or Ray Tsai (mihu). Either of us will be happy to help out.&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing dummy classes that emulate the code unit&#039;s environment. These dummy objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour. See [[Unit_Testing_Mock_Objects|Mock Objects in Joomla]] for a detailed example.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]].&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--class-exclude &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-exclude /JDate.*/ Skips tests that have a class part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--class-filter &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--debug&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--sequence-exclude &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Skips tests that have a sequence part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--sequence-filter &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--test-exclude &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Skips tests that have a test part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;--test-filter &#039;&#039;regex&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;br /&gt;
&lt;br /&gt;
== How to Get it Running ==&lt;br /&gt;
&lt;br /&gt;
Before you start make sure you have installed PHPUnit and of course PHP (5!) properly...&lt;br /&gt;
&lt;br /&gt;
To get the unit tests to run on your Joomla! installation, perform the following steps:&lt;br /&gt;
* Create an instance of your Joomla! installation&lt;br /&gt;
* In the root checkout (or export) the latest version of the unit test code from SVN &#039;&#039;&amp;quot;/testing/branches/2007-12-17&amp;quot;&#039;&#039; to your installation base. This will create a &#039;&#039;&amp;quot;/unittest&amp;quot;&#039;&#039; sub-folder under your joomla installation.&lt;br /&gt;
* Create a &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file. You can copy a the file from &#039;&#039;&amp;quot;TestConfiguration-dist.php&amp;quot;&#039;&#039; that is part of the package you just have checked out.&lt;br /&gt;
* If you want to run a subset of the commands, change to the directory that contains those tests.&lt;br /&gt;
* Run the unit test from the command using the following command:&lt;br /&gt;
&lt;br /&gt;
 php runtests.php&lt;br /&gt;
&lt;br /&gt;
The unit test will the run, and the results are rendered.&lt;br /&gt;
&lt;br /&gt;
== Trouble shooting ==&lt;br /&gt;
&lt;br /&gt;
The provided configurations should work out of the box. We have seen problems with it (currently the cause is unknown). If you get an error like blow, the  solution is pretty easy.&lt;br /&gt;
&lt;br /&gt;
 file=/var/www/unittest/runtests.php&lt;br /&gt;
 posn=17&lt;br /&gt;
 base=runtests.php&lt;br /&gt;
 /var/www&lt;br /&gt;
  JPATH_BASE does not point to a valid Joomla! installation:&lt;br /&gt;
 JPATH_BASE = /var/www&lt;br /&gt;
  Please modify your copy of &amp;quot;TestConfiguration.php&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Modify the &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file and change the definition of the JPATH_BASE so it points to the path of you Joomla! installation, in the example below the Joomla! installation is installed at &amp;quot;&#039;&#039;/var/www/update&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 define(&#039;JPATH_BASE&#039;, &#039;/var/www/update&#039;);&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[http://www.phpunit.de/pocket_guide/3.2/en/index.html PHPUnit Pocket Guide]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=8087</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=8087"/>
		<updated>2008-06-21T14:02:12Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* News and Updates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{cookiejar}}&lt;br /&gt;
== News and Updates ==&lt;br /&gt;
2008 06 21: Added --class-exclude, --sequence-exclude, and --test-exclude options.&lt;br /&gt;
&lt;br /&gt;
2008 06 21: PHPUnit has been updated to version 3.2.21 with SVN rev 10436. Please update.&lt;br /&gt;
&lt;br /&gt;
== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For a good general discussion of unit testing, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with Selenium, a browser based test automation tool.&lt;br /&gt;
&lt;br /&gt;
==== Test Objects ====&lt;br /&gt;
The purpose of unit tests is to isolate a module of code. A test that tests only one thing provides better information than a test that involves several object interactions. But how do we isolate an object from its dependencies? By writing stub classes. [http://xunitpatterns.com/Mocks,%20Fakes,%20Stubs%20and%20Dummies.html xUnit Patterns] defines a the hierarchy of dummy classes, ranging from simple to complex:&lt;br /&gt;
* Dummy - Defines attributes and methods of a dummy class (not particularly useful in PHP).&lt;br /&gt;
* Fake - Provides canned responses to method calls and fixed attribute values. Good for speed.&lt;br /&gt;
* Stub - Allows the test to define responses to method calls (return values, exceptions) to simulate the dependent object.&lt;br /&gt;
* Spy - A Fake or Stub that records method calls and parameters for later analysis.&lt;br /&gt;
* Mock - A Fake or Stub with a set of expectations -- method calls and parameters -- that are automatically verified for correctness.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests.&lt;br /&gt;
&lt;br /&gt;
For an overview of unit testing status in Joomla visit the [[Unit_Testing_Status]] page.&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in &#039;&#039;&#039;/testing/branches/2007-12-17&#039;&#039;&#039;. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== The Unit Test Team ====&lt;br /&gt;
If you can commit to the Joomla code base, then you should consider yourself part of the unit test team!&lt;br /&gt;
&lt;br /&gt;
Writing tests concurrently with code (or even before) is a good way to not only save development time, but a great tool for defending against regressions. Writing tests early in the development cycle also helps identify and resolve design issues sooner, which reduces refactoring.&lt;br /&gt;
&lt;br /&gt;
If you want to get started on unit testing, get in touch with Alan Langford (instance) or Ray Tsai (mihu). Either of us will be happy to help out.&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing dummy classes that emulate the code unit&#039;s environment. These dummy objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour. See [[Unit_Testing_Mock_Objects|Mock Objects in Joomla]] for a detailed example.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]].&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
--class-exclude &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-exclude /JDate.*/ Skips tests that have a class part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
--class-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
--debug&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
--help&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
--sequence-exclude &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Skips tests that have a sequence part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
--sequence-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--test-exclude &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Skips tests that have a test part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
--test-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;br /&gt;
&lt;br /&gt;
== How to Get it Running ==&lt;br /&gt;
&lt;br /&gt;
Before you start make sure you have installed PHPUnit and of course PHP (5!) properly...&lt;br /&gt;
&lt;br /&gt;
To get the unit tests to run on your Joomla! installation, perform the following steps:&lt;br /&gt;
* Create an instance of your Joomla! installation&lt;br /&gt;
* In the root checkout (or export) the latest version of the unit test code from SVN &#039;&#039;&amp;quot;/testing/branches/2007-12-17&amp;quot;&#039;&#039; to your installation base. This will create a &#039;&#039;&amp;quot;/unittest&amp;quot;&#039;&#039; sub-folder under your joomla installation.&lt;br /&gt;
* Create a &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file. You can copy a the file from &#039;&#039;&amp;quot;TestConfiguration-dist.php&amp;quot;&#039;&#039; that is part of the package you just have checked out.&lt;br /&gt;
* If you want to run a subset of the commands, change to the directory that contains those tests.&lt;br /&gt;
* Run the unit test from the command using the following command:&lt;br /&gt;
&lt;br /&gt;
 php runtests.php&lt;br /&gt;
&lt;br /&gt;
The unit test will the run, and the results are rendered.&lt;br /&gt;
&lt;br /&gt;
== Trouble shooting ==&lt;br /&gt;
&lt;br /&gt;
The provided configurations should work out of the box. We have seen problems with it (currently the cause is unknown). If you get an error like blow, the  solution is pretty easy.&lt;br /&gt;
&lt;br /&gt;
 file=/var/www/unittest/runtests.php&lt;br /&gt;
 posn=17&lt;br /&gt;
 base=runtests.php&lt;br /&gt;
 /var/www&lt;br /&gt;
  JPATH_BASE does not point to a valid Joomla! installation:&lt;br /&gt;
 JPATH_BASE = /var/www&lt;br /&gt;
  Please modify your copy of &amp;quot;TestConfiguration.php&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Modify the &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file and change the definition of the JPATH_BASE so it points to the path of you Joomla! installation, in the example below the Joomla! installation is installed at &amp;quot;&#039;&#039;/var/www/update&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 define(&#039;JPATH_BASE&#039;, &#039;/var/www/update&#039;);&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[http://www.phpunit.de/pocket_guide/3.2/en/index.html PHPUnit Pocket Guide]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=8086</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=8086"/>
		<updated>2008-06-21T13:59:41Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Running Unit Tests */  Added docs for the new exclude filters.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{cookiejar}}&lt;br /&gt;
== News and Updates ==&lt;br /&gt;
2008 06 21: PHPUnit has been updated to version 3.2.21 with SVN rev 10436. Please update.&lt;br /&gt;
&lt;br /&gt;
== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For a good general discussion of unit testing, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with Selenium, a browser based test automation tool.&lt;br /&gt;
&lt;br /&gt;
==== Test Objects ====&lt;br /&gt;
The purpose of unit tests is to isolate a module of code. A test that tests only one thing provides better information than a test that involves several object interactions. But how do we isolate an object from its dependencies? By writing stub classes. [http://xunitpatterns.com/Mocks,%20Fakes,%20Stubs%20and%20Dummies.html xUnit Patterns] defines a the hierarchy of dummy classes, ranging from simple to complex:&lt;br /&gt;
* Dummy - Defines attributes and methods of a dummy class (not particularly useful in PHP).&lt;br /&gt;
* Fake - Provides canned responses to method calls and fixed attribute values. Good for speed.&lt;br /&gt;
* Stub - Allows the test to define responses to method calls (return values, exceptions) to simulate the dependent object.&lt;br /&gt;
* Spy - A Fake or Stub that records method calls and parameters for later analysis.&lt;br /&gt;
* Mock - A Fake or Stub with a set of expectations -- method calls and parameters -- that are automatically verified for correctness.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests.&lt;br /&gt;
&lt;br /&gt;
For an overview of unit testing status in Joomla visit the [[Unit_Testing_Status]] page.&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in &#039;&#039;&#039;/testing/branches/2007-12-17&#039;&#039;&#039;. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== The Unit Test Team ====&lt;br /&gt;
If you can commit to the Joomla code base, then you should consider yourself part of the unit test team!&lt;br /&gt;
&lt;br /&gt;
Writing tests concurrently with code (or even before) is a good way to not only save development time, but a great tool for defending against regressions. Writing tests early in the development cycle also helps identify and resolve design issues sooner, which reduces refactoring.&lt;br /&gt;
&lt;br /&gt;
If you want to get started on unit testing, get in touch with Alan Langford (instance) or Ray Tsai (mihu). Either of us will be happy to help out.&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing dummy classes that emulate the code unit&#039;s environment. These dummy objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour. See [[Unit_Testing_Mock_Objects|Mock Objects in Joomla]] for a detailed example.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]].&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
--class-exclude &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-exclude /JDate.*/ Skips tests that have a class part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
--class-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
--debug&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
--help&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
--sequence-exclude &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Skips tests that have a sequence part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
--sequence-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--test-exclude &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Skips tests that have a test part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
--test-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that match the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;br /&gt;
&lt;br /&gt;
== How to Get it Running ==&lt;br /&gt;
&lt;br /&gt;
Before you start make sure you have installed PHPUnit and of course PHP (5!) properly...&lt;br /&gt;
&lt;br /&gt;
To get the unit tests to run on your Joomla! installation, perform the following steps:&lt;br /&gt;
* Create an instance of your Joomla! installation&lt;br /&gt;
* In the root checkout (or export) the latest version of the unit test code from SVN &#039;&#039;&amp;quot;/testing/branches/2007-12-17&amp;quot;&#039;&#039; to your installation base. This will create a &#039;&#039;&amp;quot;/unittest&amp;quot;&#039;&#039; sub-folder under your joomla installation.&lt;br /&gt;
* Create a &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file. You can copy a the file from &#039;&#039;&amp;quot;TestConfiguration-dist.php&amp;quot;&#039;&#039; that is part of the package you just have checked out.&lt;br /&gt;
* If you want to run a subset of the commands, change to the directory that contains those tests.&lt;br /&gt;
* Run the unit test from the command using the following command:&lt;br /&gt;
&lt;br /&gt;
 php runtests.php&lt;br /&gt;
&lt;br /&gt;
The unit test will the run, and the results are rendered.&lt;br /&gt;
&lt;br /&gt;
== Trouble shooting ==&lt;br /&gt;
&lt;br /&gt;
The provided configurations should work out of the box. We have seen problems with it (currently the cause is unknown). If you get an error like blow, the  solution is pretty easy.&lt;br /&gt;
&lt;br /&gt;
 file=/var/www/unittest/runtests.php&lt;br /&gt;
 posn=17&lt;br /&gt;
 base=runtests.php&lt;br /&gt;
 /var/www&lt;br /&gt;
  JPATH_BASE does not point to a valid Joomla! installation:&lt;br /&gt;
 JPATH_BASE = /var/www&lt;br /&gt;
  Please modify your copy of &amp;quot;TestConfiguration.php&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Modify the &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file and change the definition of the JPATH_BASE so it points to the path of you Joomla! installation, in the example below the Joomla! installation is installed at &amp;quot;&#039;&#039;/var/www/update&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 define(&#039;JPATH_BASE&#039;, &#039;/var/www/update&#039;);&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[http://www.phpunit.de/pocket_guide/3.2/en/index.html PHPUnit Pocket Guide]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=8082</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=8082"/>
		<updated>2008-06-21T13:17:46Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Unit Testing */  Added news and update section.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{cookiejar}}&lt;br /&gt;
== News and Updates ==&lt;br /&gt;
2008 06 21: PHPUnit has been updated to version 3.2.21 with SVN rev 10436. Please update.&lt;br /&gt;
&lt;br /&gt;
== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For a good general discussion of unit testing, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with Selenium, a browser based test automation tool.&lt;br /&gt;
&lt;br /&gt;
==== Test Objects ====&lt;br /&gt;
The purpose of unit tests is to isolate a module of code. A test that tests only one thing provides better information than a test that involves several object interactions. But how do we isolate an object from its dependencies? By writing stub classes. [http://xunitpatterns.com/Mocks,%20Fakes,%20Stubs%20and%20Dummies.html xUnit Patterns] defines a the hierarchy of dummy classes, ranging from simple to complex:&lt;br /&gt;
* Dummy - Defines attributes and methods of a dummy class (not particularly useful in PHP).&lt;br /&gt;
* Fake - Provides canned responses to method calls and fixed attribute values. Good for speed.&lt;br /&gt;
* Stub - Allows the test to define responses to method calls (return values, exceptions) to simulate the dependent object.&lt;br /&gt;
* Spy - A Fake or Stub that records method calls and parameters for later analysis.&lt;br /&gt;
* Mock - A Fake or Stub with a set of expectations -- method calls and parameters -- that are automatically verified for correctness.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests.&lt;br /&gt;
&lt;br /&gt;
For an overview of unit testing status in Joomla visit the [[Unit_Testing_Status]] page.&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in &#039;&#039;&#039;/testing/branches/2007-12-17&#039;&#039;&#039;. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== The Unit Test Team ====&lt;br /&gt;
If you can commit to the Joomla code base, then you should consider yourself part of the unit test team!&lt;br /&gt;
&lt;br /&gt;
Writing tests concurrently with code (or even before) is a good way to not only save development time, but a great tool for defending against regressions. Writing tests early in the development cycle also helps identify and resolve design issues sooner, which reduces refactoring.&lt;br /&gt;
&lt;br /&gt;
If you want to get started on unit testing, get in touch with Alan Langford (instance) or Ray Tsai (mihu). Either of us will be happy to help out.&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing dummy classes that emulate the code unit&#039;s environment. These dummy objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour. See [[Unit_Testing_Mock_Objects|Mock Objects in Joomla]] for a detailed example.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]].&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
--class-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--debug&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
--help&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
--sequence-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--test-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;br /&gt;
&lt;br /&gt;
== How to Get it Running ==&lt;br /&gt;
&lt;br /&gt;
Before you start make sure you have installed PHPUnit and of course PHP (5!) properly...&lt;br /&gt;
&lt;br /&gt;
To get the unit tests to run on your Joomla! installation, perform the following steps:&lt;br /&gt;
* Create an instance of your Joomla! installation&lt;br /&gt;
* In the root checkout (or export) the latest version of the unit test code from SVN &#039;&#039;&amp;quot;/testing/branches/2007-12-17&amp;quot;&#039;&#039; to your installation base. This will create a &#039;&#039;&amp;quot;/unittest&amp;quot;&#039;&#039; sub-folder under your joomla installation.&lt;br /&gt;
* Create a &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file. You can copy a the file from &#039;&#039;&amp;quot;TestConfiguration-dist.php&amp;quot;&#039;&#039; that is part of the package you just have checked out.&lt;br /&gt;
* If you want to run a subset of the commands, change to the directory that contains those tests.&lt;br /&gt;
* Run the unit test from the command using the following command:&lt;br /&gt;
&lt;br /&gt;
 php runtests.php&lt;br /&gt;
&lt;br /&gt;
The unit test will the run, and the results are rendered.&lt;br /&gt;
&lt;br /&gt;
== Trouble shooting ==&lt;br /&gt;
&lt;br /&gt;
The provided configurations should work out of the box. We have seen problems with it (currently the cause is unknown). If you get an error like blow, the  solution is pretty easy.&lt;br /&gt;
&lt;br /&gt;
 file=/var/www/unittest/runtests.php&lt;br /&gt;
 posn=17&lt;br /&gt;
 base=runtests.php&lt;br /&gt;
 /var/www&lt;br /&gt;
  JPATH_BASE does not point to a valid Joomla! installation:&lt;br /&gt;
 JPATH_BASE = /var/www&lt;br /&gt;
  Please modify your copy of &amp;quot;TestConfiguration.php&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Modify the &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file and change the definition of the JPATH_BASE so it points to the path of you Joomla! installation, in the example below the Joomla! installation is installed at &amp;quot;&#039;&#039;/var/www/update&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 define(&#039;JPATH_BASE&#039;, &#039;/var/www/update&#039;);&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[http://www.phpunit.de/pocket_guide/3.2/en/index.html PHPUnit Pocket Guide]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Pizza_Bugs_and_Fun_2&amp;diff=8080</id>
		<title>Pizza Bugs and Fun 2</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Pizza_Bugs_and_Fun_2&amp;diff=8080"/>
		<updated>2008-06-21T11:16:52Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Internet Relay Chat (IRC) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:pbf.png|right]]&lt;br /&gt;
{{RightTOC}}&lt;br /&gt;
We eagerly announce the second Joomla! Pizza Bug and Fun event scheduled for the weekends of &#039;&#039;&#039;June 21 and 22&#039;&#039;&#039; and &#039;&#039;&#039;June 28 and 29&#039;&#039;&#039;. It&#039;s hard to believe that six months have passed since the first Joomla! Pizza Bug and Fun event. The first PBF helped finalize Joomla! 1.5 and, if all goes as planned, this second event will help prepare Joomla! 1.5.4 for release early in July.&lt;br /&gt;
&lt;br /&gt;
This wiki will be used as the central resource for coordinating efforts and accumulating results from this event. &lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Bugs&#039;&#039;&#039; : For our first PBF event, we targeted priority 1 and 2 bugs and tested the entire application. Since it&#039;s release, Joomla! 1.5 has been very stable and there are no serious bugs to fix. But, there are a number of medium priority items that require patches and testing. If we are able to empty the tracker during the weekend, it would be an important accomplishment for the community.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Documentation&#039;&#039;&#039; : since the last [[Doc Camp 1|Doc Camp]] a lot of documentation has been written, but we need more of it. If you want to help out writing documentation, you&#039;re also more than welcome.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Unit testing&#039;&#039;&#039; : we have started writing unit tests for Joomla! This is documented in the wiki, see [[Unit Testing]] for details. This is a very important part to improve the overall quality of Joomla! and increase development speed. If you have experience in this area, we challenge you to come help us.&lt;br /&gt;
&lt;br /&gt;
== FAQ ==&lt;br /&gt;
Below you will find as much as possible information we can share on how this events is organized. If you don&#039;t find what you are looking for, you can check out the [[PBF FAQ]].&lt;br /&gt;
&lt;br /&gt;
== Organization, logistics and communications ==&lt;br /&gt;
&lt;br /&gt;
Managing this event will be a challenge. The team of [[Pizza couriers]] is working on the organization of this event, taking care of all logistics, infrastructure and communications.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Read this blog for information on how to get started when you arrive for the Pizza, Bugs and Fun event:&#039;&#039;&#039;&lt;br /&gt;
 see http://developer.joomla.org/home/26-coordinator-blog/147-the-best-ingredients-for-a-nice-pizza.html&lt;br /&gt;
&lt;br /&gt;
== Locations ==&lt;br /&gt;
&lt;br /&gt;
If you want to get people together and have a venue to share, please add it below. Share as much as possible details like exact location, url for more information about the venue, ways to register, date and time the venue is available etc. If you have any questions regarding this, feel free to contact Wilco Jansen (wilco.jansen@joomla.org).&lt;br /&gt;
&lt;br /&gt;
=== Europe ===&lt;br /&gt;
 Hotel La Meridiana&lt;br /&gt;
 Viale Italia 198 - Marina Romea 48010 Ravenna (Ra) Italy &lt;br /&gt;
 28 June 2008&lt;br /&gt;
 Additional information [http://www.joomladay.it/ www.joomladay.it]  &lt;br /&gt;
 To register post [http://forum.joomla.it/index.php/topic,44604.0.html here]&lt;br /&gt;
 [http://www.joomladay.it/component/option,com_contact/task,view/contact_id,1/Itemid,2 Contacts] &lt;br /&gt;
&lt;br /&gt;
 JUG Catalan Countries&lt;br /&gt;
 June 21. Can Domenge Centre Tecnologic. Soldat Arrom quart, 1.  Palma de Mallorca   Spain&lt;br /&gt;
 [http://www.joomla.cat JUG Catalan Countries Website]&lt;br /&gt;
&lt;br /&gt;
 There will also be a location in the Netherlands (Amsterdam, Rotterdam or Eindhoven, most likely it will be Rotterdam)&lt;br /&gt;
 If you are interested please send a mail to wilco.jansen@joomla.org&lt;br /&gt;
&lt;br /&gt;
=== North America ===&lt;br /&gt;
&lt;br /&gt;
 Webimagery, LLC&lt;br /&gt;
 843 Carondelet St. Suite 6&lt;br /&gt;
 New Orleans, LA 70130&lt;br /&gt;
 USA&lt;br /&gt;
 [http://jpbf2nola1.eventbrite.com June 21 Registration]&lt;br /&gt;
 [http://jpbf2nola2.eventbrite.com June 22 Registration]&lt;br /&gt;
&lt;br /&gt;
 PICnet, Inc. (DC)&lt;br /&gt;
 1341 G St, NW, Suite 1100&lt;br /&gt;
 Washington DC, 20005&lt;br /&gt;
 [http://www.joomladayusa.org/index.php?option=com_events&amp;amp;type=event&amp;amp;task=details&amp;amp;id=6&amp;amp;Itemid=11 Registration Page]&lt;br /&gt;
&lt;br /&gt;
 New York City JUG&lt;br /&gt;
 Address to be verified shortly&lt;br /&gt;
 [http://www.joomlanyc.org Joomla NYC Website]&lt;br /&gt;
&lt;br /&gt;
 Vancouver, BC, Canada&lt;br /&gt;
 822 Homer (at Robson) &lt;br /&gt;
 Across from where the JoomlaDay event was held.&lt;br /&gt;
 Call Mike Hamanaka or Amir Sharifnejad at +1-604-626-9225 and we will buzz you in.&lt;br /&gt;
 [website to be announced]&lt;br /&gt;
&lt;br /&gt;
=== South America ===&lt;br /&gt;
 No venue registered&lt;br /&gt;
&lt;br /&gt;
=== Asia/Pacific ===&lt;br /&gt;
&lt;br /&gt;
 Spike Systems Pty Ltd&lt;br /&gt;
 Level 6, 99 York Street&lt;br /&gt;
 Sydney.&lt;br /&gt;
 Map here: http://tinyurl.com/4gwatl&lt;br /&gt;
 URL with additional information will follow soon (including registration option). &lt;br /&gt;
&lt;br /&gt;
------&lt;br /&gt;
 Please enter your location in Asia here, provide us with:&lt;br /&gt;
 location and name of the venue, date(s)/time (don&#039;t forget the timezone), &lt;br /&gt;
 url for more info, how to register, contact option&lt;br /&gt;
&lt;br /&gt;
=== Africa ===&lt;br /&gt;
 No venue registered&lt;br /&gt;
&lt;br /&gt;
===Cyberspace===&lt;br /&gt;
====Internet Relay Chat (IRC)====&lt;br /&gt;
Freenode channel [irc://irc.freenode.net/joomlapbf #joomlapbf] from 21 to 22 June 2008, all times, all timezones.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have an IRC client installed, use this link: [http://www.joomlanyc.org/index.php?option=com_wrapper&amp;amp;Itemid=23 #joomlapbf]. This is a web-based IRC client.&lt;br /&gt;
&lt;br /&gt;
This channel is available now and throughout the event. We might set up additional channels, if we do they will be listed above.&lt;br /&gt;
&lt;br /&gt;
== Registration ==&lt;br /&gt;
=== For write access to this wiki ===&lt;br /&gt;
To get write access to this wiki you will need to [[Special:Userlogin|register here first]].  Please be aware that the registration process requires a valid email address.  If you are traveling to one of the physical locations you are advised to ensure that you have registered on this wiki and have a valid login before you travel. You don&#039;t need access to your email account after registration.&lt;br /&gt;
&lt;br /&gt;
=== At a physical location ===&lt;br /&gt;
If you wish to be present at one of the physical locations listed above then you must register in advance because space most likely is limited.  Registrations are the responsibility of the individual location organizers and you should click on the appropriate link above for more information.&lt;br /&gt;
&lt;br /&gt;
=== Taking bugs, tasks and pizza ===&lt;br /&gt;
Pizza can be ordered at a shop near by :-)&lt;br /&gt;
&lt;br /&gt;
Please check the [http://docs.joomla.org/Pizza_Bugs_and_Fun_2#Organization.2C_logistics_and_communications Organization, logistics and communications section] for detail on how to get involved in working on tasks.&lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
* All code must be made available under the [http://www.gnu.org/licenses/gpl-2.0.html General Public Licence version 2].&lt;br /&gt;
* All documentation contributions must be made available under the [[JEDL|Joomla! Electronic Documentation License]]. Further information on the JEDL is available in the [[JEDL/FAQ|JEDL Frequently Asked Questions]]&lt;br /&gt;
* No advertising or self-promotion will be allowed.  This includes back links to your website or anyone else&#039;s.  The one exception is that if you have made a contribution then feel free to add your name and an optional link to your website to the [[PBF Contributors List]]&lt;br /&gt;
* All contributions must be in English.  Note that the official language of the Joomla! project is British/Australian English.&lt;br /&gt;
{{:PBF_Contributors_List}}&lt;br /&gt;
[[Category: Development]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Pizza_Bugs_and_Fun_2/Contributors_List&amp;diff=7995</id>
		<title>Pizza Bugs and Fun 2/Contributors List</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Pizza_Bugs_and_Fun_2/Contributors_List&amp;diff=7995"/>
		<updated>2008-06-20T13:59:34Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Contributors to the second PBF */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;If you made a contribution to the documentation held on this site, please feel free to add your name below.  Please consider adding your real name in addition to your nickname.  You may, optionally, include a link to your website.&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Contributors to the second PBF ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font color=red&amp;gt;&#039;&#039;&#039;The people below plan to participate to PBF. Afterwards the list will be validated for the present we are planning. Those who haven&#039;t participated will be removed from this list afterward.&#039;&#039;&#039;&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Chris Davenport ([[Special:Contributions/Chris_Davenport|contributions]])&lt;br /&gt;
* Kevin Devine ([[Special:Contributions/Kevin_Devine|contributions]])&lt;br /&gt;
* Anthony Ferrara ([[Special:Contributions/ircmaxell|contributions]])&lt;br /&gt;
* Jerry Hilburn ([[Special:Contributions/Jerry_Hilburn|contributions]])&lt;br /&gt;
* Louis Landry ([[Special:Contributions/Louis_Landry|contributions]])&lt;br /&gt;
* Wilco Jansen ([[Special:Contributions/willebil|contributions]])&lt;br /&gt;
* Jennifer Marriott ([[Special:Contributions/MMMedia|contributions]])&lt;br /&gt;
* Rob Schley ([[Special:Contributions/Rob_Schley|contributions]])&lt;br /&gt;
* Amy Stephen ([[Special:Contributions/AmyStephen|contributions]])&lt;br /&gt;
* Nereyda Valentin-Macias ([[Special:Contributions/Neriv|contributions]])&lt;br /&gt;
* Elin Waring ([[Special:Contributions/Elin|contributions]])&lt;br /&gt;
* Michael Casha ([[Special:Contributions/MiCCAS|contributions]])&lt;br /&gt;
* Phil Taylor ([[Special:Contributions/Prazgod|contributions]])&lt;br /&gt;
* Marcelo Eden ([[Special:Contributions/3dentech|contributions]])&lt;br /&gt;
* Matt Thomas ([[Special:Contributions/betweenbrain|contributions]])&lt;br /&gt;
* Ross Crawford ([[Special:Contributions/RoscoHead|contributions]])&lt;br /&gt;
* Mickael Maison ([[Special:Contributions/Mmaison|contributions]])&lt;br /&gt;
* Ian MacLennan ([[Special:Contributions/ian|contributions]])&lt;br /&gt;
* Jaap Woltjes ([[Special:Contributions/japie1001|contributions]])&lt;br /&gt;
* Alan Langford ([[Special:Contributions/Instance|contributions]])&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=7308</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=7308"/>
		<updated>2008-05-23T16:33:08Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* How to Get it Running */ A little more formatting and add test subset tip.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{cookiejar}}&lt;br /&gt;
== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For a good general discussion of unit testing, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with Selenium, a browser based test automation tool.&lt;br /&gt;
&lt;br /&gt;
==== Test Objects ====&lt;br /&gt;
The purpose of unit tests is to isolate a module of code. A test that tests only one thing provides better information than a test that involves several object interactions. But how do we isolate an object from its dependencies? By writing stub classes. [http://xunitpatterns.com/Mocks,%20Fakes,%20Stubs%20and%20Dummies.html xUnit Patterns] defines a the hierarchy of dummy classes, ranging from simple to complex:&lt;br /&gt;
* Dummy - Defines attributes and methods of a dummy class (not particularly useful in PHP).&lt;br /&gt;
* Fake - Provides canned responses to method calls and fixed attribute values. Good for speed.&lt;br /&gt;
* Stub - Allows the test to define responses to method calls (return values, exceptions) to simulate the dependent object.&lt;br /&gt;
* Spy - A Fake or Stub that records method calls and parameters for later analysis.&lt;br /&gt;
* Mock - A Fake or Stub with a set of expectations -- method calls and parameters -- that are automatically verified for correctness.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in &#039;&#039;&#039;/testing/branches/2007-12-17&#039;&#039;&#039;. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== The Unit Test Team ====&lt;br /&gt;
If you can commit to the Joomla code base, then you should consider yourself part of the unit test team!&lt;br /&gt;
&lt;br /&gt;
Writing tests concurrently with code (or even before) is a good way to not only save development time, but a great tool for defending against regressions. Writing tests early in the development cycle also helps identify and resolve design issues sooner, which reduces refactoring.&lt;br /&gt;
&lt;br /&gt;
If you want to get started on unit testing, get in touch with Alan Langford (instance) or Ray Tsai (mihu). Either of us will be happy to help out.&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing dummy classes that emulate the code unit&#039;s environment. These dummy objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour. See [[Unit_Testing_Mock_Objects|Mock Objects in Joomla]] for a detailed example.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]].&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
--class-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--debug&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
--help&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
--sequence-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--test-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;br /&gt;
&lt;br /&gt;
== How to Get it Running ==&lt;br /&gt;
&lt;br /&gt;
Before you start make sure you have installed PHPUnit and of course PHP (5!) properly...&lt;br /&gt;
&lt;br /&gt;
To get the unit tests to run on your Joomla! installation, perform the following steps:&lt;br /&gt;
* Create an instance of your Joomla! installation&lt;br /&gt;
* In the root checkout (or export) the latest version of the unit test code from SVN &#039;&#039;&amp;quot;/testing/branches/2007-12-17&amp;quot;&#039;&#039; to your installation base. This will create a &#039;&#039;&amp;quot;/unittest&amp;quot;&#039;&#039; sub-folder under your joomla installation.&lt;br /&gt;
* Create a &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file. You can copy a the file from &#039;&#039;&amp;quot;TestConfiguration-dist.php&amp;quot;&#039;&#039; that is part of the package you just have checked out.&lt;br /&gt;
* If you want to run a subset of the commands, change to the directory that contains those tests.&lt;br /&gt;
* Run the unit test from the command using the following command:&lt;br /&gt;
&lt;br /&gt;
 php runtests.php&lt;br /&gt;
&lt;br /&gt;
The unit test will the run, and the results are rendered.&lt;br /&gt;
&lt;br /&gt;
== Trouble shooting ==&lt;br /&gt;
&lt;br /&gt;
The provided configurations should work out of the box. We have seen problems with it (currently the cause is unknown). If you get an error like blow, the  solution is pretty easy.&lt;br /&gt;
&lt;br /&gt;
 file=/var/www/unittest/runtests.php&lt;br /&gt;
 posn=17&lt;br /&gt;
 base=runtests.php&lt;br /&gt;
 /var/www&lt;br /&gt;
  JPATH_BASE does not point to a valid Joomla! installation:&lt;br /&gt;
 JPATH_BASE = /var/www&lt;br /&gt;
  Please modify your copy of &amp;quot;TestConfiguration.php&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Modify the &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file and change the definition of the JPATH_BASE so it points to the path of you Joomla! installation, in the example below the Joomla! installation is installed at &amp;quot;&#039;&#039;/var/www/update&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 define(&#039;JPATH_BASE&#039;, &#039;/var/www/update&#039;);&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=7307</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=7307"/>
		<updated>2008-05-23T16:30:07Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* How to get it running */ Formatting fixes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{cookiejar}}&lt;br /&gt;
== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For a good general discussion of unit testing, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with Selenium, a browser based test automation tool.&lt;br /&gt;
&lt;br /&gt;
==== Test Objects ====&lt;br /&gt;
The purpose of unit tests is to isolate a module of code. A test that tests only one thing provides better information than a test that involves several object interactions. But how do we isolate an object from its dependencies? By writing stub classes. [http://xunitpatterns.com/Mocks,%20Fakes,%20Stubs%20and%20Dummies.html xUnit Patterns] defines a the hierarchy of dummy classes, ranging from simple to complex:&lt;br /&gt;
* Dummy - Defines attributes and methods of a dummy class (not particularly useful in PHP).&lt;br /&gt;
* Fake - Provides canned responses to method calls and fixed attribute values. Good for speed.&lt;br /&gt;
* Stub - Allows the test to define responses to method calls (return values, exceptions) to simulate the dependent object.&lt;br /&gt;
* Spy - A Fake or Stub that records method calls and parameters for later analysis.&lt;br /&gt;
* Mock - A Fake or Stub with a set of expectations -- method calls and parameters -- that are automatically verified for correctness.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in &#039;&#039;&#039;/testing/branches/2007-12-17&#039;&#039;&#039;. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== The Unit Test Team ====&lt;br /&gt;
If you can commit to the Joomla code base, then you should consider yourself part of the unit test team!&lt;br /&gt;
&lt;br /&gt;
Writing tests concurrently with code (or even before) is a good way to not only save development time, but a great tool for defending against regressions. Writing tests early in the development cycle also helps identify and resolve design issues sooner, which reduces refactoring.&lt;br /&gt;
&lt;br /&gt;
If you want to get started on unit testing, get in touch with Alan Langford (instance) or Ray Tsai (mihu). Either of us will be happy to help out.&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing dummy classes that emulate the code unit&#039;s environment. These dummy objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour. See [[Unit_Testing_Mock_Objects|Mock Objects in Joomla]] for a detailed example.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]].&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
--class-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--debug&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
--help&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
--sequence-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--test-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;br /&gt;
&lt;br /&gt;
== How to Get it Running ==&lt;br /&gt;
&lt;br /&gt;
Before you start make sure you have installed PHPUnit and of course PHP (5!) properly...&lt;br /&gt;
&lt;br /&gt;
To get the unit tests to run on your Joomla! installation, perform the following steps:&lt;br /&gt;
* Create an instance of your Joomla! installation&lt;br /&gt;
* In the root checkout (or export) the latest version of the unit test code from SVN &#039;&#039;&amp;quot;/testing/branches/2007-12-17&amp;quot;&#039;&#039; to your installation base. This will create a &#039;&#039;&amp;quot;/unittest&amp;quot;&#039;&#039; (sub-folder under your joomla installation).&lt;br /&gt;
* Create a &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file. You can copy a the file from &#039;&#039;&amp;quot;TestConfiguration-dist.php&amp;quot;&#039;&#039; that is part of the package you just have checked out.&lt;br /&gt;
* Run the unit test from the command using the following command:&lt;br /&gt;
&lt;br /&gt;
 php runtests.php&lt;br /&gt;
&lt;br /&gt;
The unit test will the run, and the results are rendered.&lt;br /&gt;
&lt;br /&gt;
== Trouble shooting ==&lt;br /&gt;
&lt;br /&gt;
The provided configurations should work out of the box. We have seen problems with it (currently the cause is unknown). If you get an error like blow, the  solution is pretty easy.&lt;br /&gt;
&lt;br /&gt;
 file=/var/www/unittest/runtests.php&lt;br /&gt;
 posn=17&lt;br /&gt;
 base=runtests.php&lt;br /&gt;
 /var/www&lt;br /&gt;
  JPATH_BASE does not point to a valid Joomla! installation:&lt;br /&gt;
 JPATH_BASE = /var/www&lt;br /&gt;
  Please modify your copy of &amp;quot;TestConfiguration.php&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Modify the &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file and change the definition of the JPATH_BASE so it points to the path of you Joomla! installation, in the example below the Joomla! installation is installed at &amp;quot;&#039;&#039;/var/www/update&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 define(&#039;JPATH_BASE&#039;, &#039;/var/www/update&#039;);&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=7306</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=7306"/>
		<updated>2008-05-23T16:28:16Z</updated>

		<summary type="html">&lt;p&gt;Instance: Make the branch location more obvious.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{cookiejar}}&lt;br /&gt;
== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For a good general discussion of unit testing, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with Selenium, a browser based test automation tool.&lt;br /&gt;
&lt;br /&gt;
==== Test Objects ====&lt;br /&gt;
The purpose of unit tests is to isolate a module of code. A test that tests only one thing provides better information than a test that involves several object interactions. But how do we isolate an object from its dependencies? By writing stub classes. [http://xunitpatterns.com/Mocks,%20Fakes,%20Stubs%20and%20Dummies.html xUnit Patterns] defines a the hierarchy of dummy classes, ranging from simple to complex:&lt;br /&gt;
* Dummy - Defines attributes and methods of a dummy class (not particularly useful in PHP).&lt;br /&gt;
* Fake - Provides canned responses to method calls and fixed attribute values. Good for speed.&lt;br /&gt;
* Stub - Allows the test to define responses to method calls (return values, exceptions) to simulate the dependent object.&lt;br /&gt;
* Spy - A Fake or Stub that records method calls and parameters for later analysis.&lt;br /&gt;
* Mock - A Fake or Stub with a set of expectations -- method calls and parameters -- that are automatically verified for correctness.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in &#039;&#039;&#039;/testing/branches/2007-12-17&#039;&#039;&#039;. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== The Unit Test Team ====&lt;br /&gt;
If you can commit to the Joomla code base, then you should consider yourself part of the unit test team!&lt;br /&gt;
&lt;br /&gt;
Writing tests concurrently with code (or even before) is a good way to not only save development time, but a great tool for defending against regressions. Writing tests early in the development cycle also helps identify and resolve design issues sooner, which reduces refactoring.&lt;br /&gt;
&lt;br /&gt;
If you want to get started on unit testing, get in touch with Alan Langford (instance) or Ray Tsai (mihu). Either of us will be happy to help out.&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing dummy classes that emulate the code unit&#039;s environment. These dummy objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour. See [[Unit_Testing_Mock_Objects|Mock Objects in Joomla]] for a detailed example.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]].&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
--class-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--debug&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
--help&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
--sequence-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--test-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;br /&gt;
&lt;br /&gt;
== How to get it running ==&lt;br /&gt;
&lt;br /&gt;
Before you start make sure you have installed PHPUnit and of course PHP (5!) properly...&lt;br /&gt;
&lt;br /&gt;
To get the unit tests to run on your Joomla! installation, perform the following steps:&lt;br /&gt;
* Create an instance of your Joomla! installation&lt;br /&gt;
* In the root checkout (or export) the latest version of the unit test code from SVN &#039;&#039;/testing/branches/2007-12-17&#039;&#039; to your installation base. This will create a &#039;&#039;&amp;quot;/unittest&amp;quot;&#039;&#039; (sub-folder under your joomla installation).&lt;br /&gt;
* Create a &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file. You can copy a the file from &#039;&#039;&amp;quot;TestConfiguration-dist.php&amp;quot;&#039;&#039; that is part of the package you just have checked out.&lt;br /&gt;
* Run the unit test from the command using the following command:&lt;br /&gt;
&lt;br /&gt;
 php runtests.php&lt;br /&gt;
&lt;br /&gt;
The unit test will the run, and the results are rendered.&lt;br /&gt;
&lt;br /&gt;
== Trouble shooting ==&lt;br /&gt;
&lt;br /&gt;
The provided configurations should work out of the box. We have seen problems with it (currently the cause is unknown). If you get an error like blow, the  solution is pretty easy.&lt;br /&gt;
&lt;br /&gt;
 file=/var/www/unittest/runtests.php&lt;br /&gt;
 posn=17&lt;br /&gt;
 base=runtests.php&lt;br /&gt;
 /var/www&lt;br /&gt;
  JPATH_BASE does not point to a valid Joomla! installation:&lt;br /&gt;
 JPATH_BASE = /var/www&lt;br /&gt;
  Please modify your copy of &amp;quot;TestConfiguration.php&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Modify the &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file and change the definition of the JPATH_BASE so it points to the path of you Joomla! installation, in the example below the Joomla! installation is installed at &amp;quot;&#039;&#039;/var/www/update&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 define(&#039;JPATH_BASE&#039;, &#039;/var/www/update&#039;);&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=6879</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=6879"/>
		<updated>2008-05-13T11:50:32Z</updated>

		<summary type="html">&lt;p&gt;Instance: A little reorganization; new information on dummy classes.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For a good general discussion of unit testing, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with Selenium, a browser based test automation tool.&lt;br /&gt;
&lt;br /&gt;
==== Test Objects ====&lt;br /&gt;
The purpose of unit tests is to isolate a module of code. A test that tests only one thing provides better information than a test that involves several object interactions. But how do we isolate an object from its dependencies? By writing stub classes. [http://xunitpatterns.com/Mocks,%20Fakes,%20Stubs%20and%20Dummies.html xUnit Patterns] defines a the hierarchy of dummy classes, ranging from simple to complex:&lt;br /&gt;
* Dummy - Defines attributes and methods of a dummy class (not particularly useful in PHP).&lt;br /&gt;
* Fake - Provides canned responses to method calls and fixed attribute values. Good for speed.&lt;br /&gt;
* Stub - Allows the test to define responses to method calls (return values, exceptions) to simulate the dependent object.&lt;br /&gt;
* Spy - A Fake or Stub that records method calls and parameters for later analysis.&lt;br /&gt;
* Mock - A Fake or Stub with a set of expectations -- method calls and parameters -- that are automatically verified for correctness.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in /testing/branches/2007-12-17. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== The Unit Test Team ====&lt;br /&gt;
If you can commit to the Joomla code base, then you should consider yourself part of the unit test team!&lt;br /&gt;
&lt;br /&gt;
Writing tests concurrently with code (or even before) is a good way to not only save development time, but a great tool for defending against regressions. Writing tests early in the development cycle also helps identify and resolve design issues sooner, which reduces refactoring.&lt;br /&gt;
&lt;br /&gt;
If you want to get started on unit testing, get in touch with Alan Langford (instance) or Ray Tsai (mihu). Either of us will be happy to help out.&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing dummy classes that emulate the code unit&#039;s environment. These dummy objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour. See [[Unit_Testing_Mock_Objects|Mock Objects in Joomla]] for a detailed example.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]].&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
--class-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--debug&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
--help&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
--sequence-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--test-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;br /&gt;
&lt;br /&gt;
== How to get it running ==&lt;br /&gt;
&lt;br /&gt;
Before you start make sure you have installed PHPUnit and of course PHP (5!) properly...&lt;br /&gt;
&lt;br /&gt;
To get the unit tests to run on your Joomla! installation, perform the following steps:&lt;br /&gt;
* Create an instance of your Joomla! installation&lt;br /&gt;
* In the root checkout (or export) the latest version of the unit test code in &#039;&#039;&amp;quot;/unittest&amp;quot;&#039;&#039; (sub-folder under your joomla installation).&lt;br /&gt;
* Create a &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file. You can copy a the file from &#039;&#039;&amp;quot;TestConfiguration-dist.php&amp;quot;&#039;&#039; that is part of the package you just have checked out.&lt;br /&gt;
* Run the unit test from the command using the following command:&lt;br /&gt;
&lt;br /&gt;
 php runtests.php&lt;br /&gt;
&lt;br /&gt;
The unit test will the run, and the results are rendered.&lt;br /&gt;
&lt;br /&gt;
== Trouble shooting ==&lt;br /&gt;
&lt;br /&gt;
The provided configurations should work out of the box. We have seen problems with it (currently the cause is unknown). If you get an error like blow, the  solution is pretty easy.&lt;br /&gt;
&lt;br /&gt;
 file=/var/www/unittest/runtests.php&lt;br /&gt;
 posn=17&lt;br /&gt;
 base=runtests.php&lt;br /&gt;
 /var/www&lt;br /&gt;
  JPATH_BASE does not point to a valid Joomla! installation:&lt;br /&gt;
 JPATH_BASE = /var/www&lt;br /&gt;
  Please modify your copy of &amp;quot;TestConfiguration.php&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Modify the &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file and change the definition of the JPATH_BASE so it points to the path of you Joomla! installation, in the example below the Joomla! installation is installed at &amp;quot;&#039;&#039;/var/www/update&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 define(&#039;JPATH_BASE&#039;, &#039;/var/www/update&#039;);&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=6878</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=6878"/>
		<updated>2008-05-13T11:26:29Z</updated>

		<summary type="html">&lt;p&gt;Instance: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For a good general discussion of unit testing, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with Selenium, a browser based test automation tool.&lt;br /&gt;
&lt;br /&gt;
==== Test Objects ====&lt;br /&gt;
The purpose of unit tests is to isolate a module of code. A test that tests only one thing provides better information than a test that involves several object interactions. But how do we isolate an object from its dependencies? By writing stub classes. [http://xunitpatterns.com/Mocks,%20Fakes,%20Stubs%20and%20Dummies.html xUnit Patterns] defines a the hierarchy of dummy classes, ranging from simple to complex:&lt;br /&gt;
* Dummy - Defines attributes and methods of a dummy class (not particularly useful in PHP).&lt;br /&gt;
* Fake - Provides canned responses to method calls and fixed attribute values. Good for speed.&lt;br /&gt;
* Stub - Allows the test to define responses to method calls (return values, exceptions) to simulate the dependent object.&lt;br /&gt;
* Spy - A Fake or Stub that records method calls and parameters for later analysis.&lt;br /&gt;
* Mock - A Fake or Stub with a set of expectations -- method calls and parameters -- that are automatically verified for correctness.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in /testing/branches/2007-12-17. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== The Unit Test Team ====&lt;br /&gt;
If you can commit to the Joomla code base, then you should consider yourself part of the unit test team!&lt;br /&gt;
&lt;br /&gt;
Writing tests concurrently with code (or even before) is a good way to not only save development time, but a great tool for defending against regressions. Writing tests early in the development cycle also helps identify and resolve design issues sooner, which reduces refactoring.&lt;br /&gt;
&lt;br /&gt;
If you want to get started on unit testing, get in touch with Alan Langford (instance) or Ray Tsai (mihu). Either of us will be happy to help out.&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
--class-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--debug&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
--help&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
--sequence-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--test-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing simple stubs that emulate the code unit&#039;s environment. These stubs are known as &amp;quot;Mock Objects&amp;quot;. Mock objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]].&lt;br /&gt;
&lt;br /&gt;
== How to get it running ==&lt;br /&gt;
&lt;br /&gt;
Before you start make sure you have installed PHPUnit and of course PHP (5!) properly...&lt;br /&gt;
&lt;br /&gt;
To get the unit tests to run on your Joomla! installation, perform the following steps:&lt;br /&gt;
* Create an instance of your Joomla! installation&lt;br /&gt;
* In the root checkout (or export) the latest version of the unit test code in &#039;&#039;&amp;quot;/unittest&amp;quot;&#039;&#039; (sub-folder under your joomla installation).&lt;br /&gt;
* Create a &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file. You can copy a the file from &#039;&#039;&amp;quot;TestConfiguration-dist.php&amp;quot;&#039;&#039; that is part of the package you just have checked out.&lt;br /&gt;
* Run the unit test from the command using the following command:&lt;br /&gt;
&lt;br /&gt;
 php runtests.php&lt;br /&gt;
&lt;br /&gt;
The unit test will the run, and the results are rendered.&lt;br /&gt;
&lt;br /&gt;
== Trouble shooting ==&lt;br /&gt;
&lt;br /&gt;
The provided configurations should work out of the box. We have seen problems with it (currently the cause is unknown). If you get an error like blow, the  solution is pretty easy.&lt;br /&gt;
&lt;br /&gt;
 file=/var/www/unittest/runtests.php&lt;br /&gt;
 posn=17&lt;br /&gt;
 base=runtests.php&lt;br /&gt;
 /var/www&lt;br /&gt;
  JPATH_BASE does not point to a valid Joomla! installation:&lt;br /&gt;
 JPATH_BASE = /var/www&lt;br /&gt;
  Please modify your copy of &amp;quot;TestConfiguration.php&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Modify the &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file and change the definition of the JPATH_BASE so it points to the path of you Joomla! installation, in the example below the Joomla! installation is installed at &amp;quot;&#039;&#039;/var/www/update&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 define(&#039;JPATH_BASE&#039;, &#039;/var/www/update&#039;);&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=5809</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=5809"/>
		<updated>2008-05-02T11:56:30Z</updated>

		<summary type="html">&lt;p&gt;Instance: Add unit test team.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For a good general discussion of unit testing, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in /testing/branches/2007-12-17. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== The Unit Test Team ====&lt;br /&gt;
If you can commit to the Joomla code base, then you should consider yourself part of the unit test team!&lt;br /&gt;
&lt;br /&gt;
Writing tests concurrently with code (or even before) is a good way to not only save development time, but a great tool for defending against regressions. Writing tests early in the development cycle also helps identify and resolve design issues sooner, which reduces refactoring.&lt;br /&gt;
&lt;br /&gt;
If you want to get started on unit testing, get in touch with Alan Langford (instance) or Ray Tsai (mihu). Either of us will be happy to help out.&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
--class-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--debug&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
--help&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
--sequence-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--test-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing simple stubs that emulate the code unit&#039;s environment. These stubs are known as &amp;quot;Mock Objects&amp;quot;. Mock objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]].&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with Selenium, a browser based test automation tool.&lt;br /&gt;
&lt;br /&gt;
== How to get it running ==&lt;br /&gt;
&lt;br /&gt;
Before you start make sure you have installed PHPUnit and of course PHP (5!) properly...&lt;br /&gt;
&lt;br /&gt;
To get the unit tests to run on your Joomla! installation, perform the following steps:&lt;br /&gt;
* Create an instance of your Joomla! installation&lt;br /&gt;
* In the root checkout (or export) the latest version of the unit test code in &#039;&#039;&amp;quot;/unittest&amp;quot;&#039;&#039; (sub-folder under your joomla installation).&lt;br /&gt;
* Create a &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file. You can copy a the file from &#039;&#039;&amp;quot;TestConfiguration-dist.php&amp;quot;&#039;&#039; that is part of the package you just have checked out.&lt;br /&gt;
* Run the unit test from the command using the following command:&lt;br /&gt;
&lt;br /&gt;
 php runtests.php&lt;br /&gt;
&lt;br /&gt;
The unit test will the run, and the results are rendered.&lt;br /&gt;
&lt;br /&gt;
== Trouble shooting ==&lt;br /&gt;
&lt;br /&gt;
The provided configurations should work out of the box. We have seen problems with it (currently the cause is unknown). If you get an error like blow, the  solution is pretty easy.&lt;br /&gt;
&lt;br /&gt;
 file=/var/www/unittest/runtests.php&lt;br /&gt;
 posn=17&lt;br /&gt;
 base=runtests.php&lt;br /&gt;
 /var/www&lt;br /&gt;
  JPATH_BASE does not point to a valid Joomla! installation:&lt;br /&gt;
 JPATH_BASE = /var/www&lt;br /&gt;
  Please modify your copy of &amp;quot;TestConfiguration.php&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Modify the &#039;&#039;&amp;quot;TestConfiguration.php&amp;quot;&#039;&#039; file and change the definition of the JPATH_BASE so it points to the path of you Joomla! installation, in the example below the Joomla! installation is installed at &amp;quot;&#039;&#039;/var/www/update&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 define(&#039;JPATH_BASE&#039;, &#039;/var/www/update&#039;);&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Archived:Code_05010&amp;diff=3619</id>
		<title>Archived:Code 05010</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Archived:Code_05010&amp;diff=3619"/>
		<updated>2008-03-20T13:40:12Z</updated>

		<summary type="html">&lt;p&gt;Instance: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Title==&lt;br /&gt;
Create Web-Based Unit Test Runner&lt;br /&gt;
&lt;br /&gt;
== One line summary ==&lt;br /&gt;
Write a test runner that makes it easy to run unit tests from a web browser.&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
The existing unit test framework is based on running PHP from the command line. While this is essential for integrating testing into the build and release process, it&#039;s a barrier to using tests during development.&lt;br /&gt;
&lt;br /&gt;
This project involves adapting web-based test runners provided by PHPUnit to support the &amp;quot;Joomla!&amp;quot; testing environment.&lt;br /&gt;
&lt;br /&gt;
== Skills needed ==&lt;br /&gt;
&lt;br /&gt;
== Difficulty ==&lt;br /&gt;
&lt;br /&gt;
== Work Product ==&lt;br /&gt;
&lt;br /&gt;
== Licensing ==&lt;br /&gt;
All code must be created using the [[http://www.gnu.org/licenses/old-licenses/gpl-2.0.html#SEC4 GNU General Public License version]]&lt;br /&gt;
&lt;br /&gt;
Documentation written for this task must be made available under the Joomla! Electronic Documentation License. &lt;br /&gt;
&lt;br /&gt;
== Possible mentor ==&lt;br /&gt;
&lt;br /&gt;
Return to [[Google Summer of Code 2008]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Google Summer of Code 2008]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Archived:Code_05010&amp;diff=3618</id>
		<title>Archived:Code 05010</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Archived:Code_05010&amp;diff=3618"/>
		<updated>2008-03-20T13:35:34Z</updated>

		<summary type="html">&lt;p&gt;Instance: New page: ==Title== Create Web-Based Unit Test Runner  == One line summary == Write a test runner that makes it easy to run unit tests from a web browser.  == Description == The existing unit test f...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Title==&lt;br /&gt;
Create Web-Based Unit Test Runner&lt;br /&gt;
&lt;br /&gt;
== One line summary ==&lt;br /&gt;
Write a test runner that makes it easy to run unit tests from a web browser.&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
The existing unit test framework is based on running PHP from the command line. While this is essential for integrating testing into the build and release process, it&#039;s a barrier to using tests during development.&lt;br /&gt;
&lt;br /&gt;
== Skills needed ==&lt;br /&gt;
&lt;br /&gt;
== Difficulty ==&lt;br /&gt;
&lt;br /&gt;
== Work Product ==&lt;br /&gt;
&lt;br /&gt;
== Licensing ==&lt;br /&gt;
All code must be created using the [[http://www.gnu.org/licenses/old-licenses/gpl-2.0.html#SEC4 GNU General Public License version]]&lt;br /&gt;
&lt;br /&gt;
Documentation written for this task must be made available under the Joomla! Electronic Documentation License. &lt;br /&gt;
&lt;br /&gt;
== Possible mentor ==&lt;br /&gt;
&lt;br /&gt;
Return to [[Google Summer of Code 2008]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Google Summer of Code 2008]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Archived:ProjectTemplate&amp;diff=3595</id>
		<title>Archived:ProjectTemplate</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Archived:ProjectTemplate&amp;diff=3595"/>
		<updated>2008-03-20T12:23:48Z</updated>

		<summary type="html">&lt;p&gt;Instance: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Title==&lt;br /&gt;
&lt;br /&gt;
== One line summary ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
== Skills needed ==&lt;br /&gt;
&lt;br /&gt;
== Difficulty ==&lt;br /&gt;
&lt;br /&gt;
== Work Product ==&lt;br /&gt;
&lt;br /&gt;
== Licensing ==&lt;br /&gt;
All code must be created using the [[http://www.gnu.org/licenses/old-licenses/gpl-2.0.html#SEC4 GNU General Public License version]]&lt;br /&gt;
&lt;br /&gt;
Documentation written for this task must be made available under the Joomla! Electronic Documentation License. &lt;br /&gt;
&lt;br /&gt;
== Possible mentor ==&lt;br /&gt;
&lt;br /&gt;
Return to [[Google Summer of Code 2008]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Google Summer of Code 2008]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Archived:Summer_of_Code_2008_Project_Ideas&amp;diff=3594</id>
		<title>Archived:Summer of Code 2008 Project Ideas</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Archived:Summer_of_Code_2008_Project_Ideas&amp;diff=3594"/>
		<updated>2008-03-20T12:20:52Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Unit testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains a list of project proposal ideas from the Joomla! Project (community members). The mentoring organization has written down a non-exhaustive list of project ideas to guide the students into selecting a suitable idea.&lt;br /&gt;
&lt;br /&gt;
This list will be updated on a regular basis. Feel free to post any other ideas into into the [http://forum.joomla.org/viewforum.php?f=525 Google Summer of Code 2008 Forum Area] or use the [http://groups.google.com/group/joomla-summer-of-code-2008 Google Summer of Code mail list] (don&#039;t forget to register in the forum and list before you post).&lt;br /&gt;
 &lt;br /&gt;
We would kindly ask you not to add new projects here unless you are one of the project mentors. Please discuss these on the list/forum mentioned above.&lt;br /&gt;
&lt;br /&gt;
[[ProjectTemplate]]&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
&lt;br /&gt;
 [[Code 01000]] Article Versioning&lt;br /&gt;
 [[Code 01010]] Multi-site implementation&lt;br /&gt;
 [[Code 01020]] Whiteboard component&lt;br /&gt;
 [[Code 01030]] Image Manager improvements&lt;br /&gt;
 [[Code 01040]] Create a forms component/extension&lt;br /&gt;
 [[Code 01050]] Export and Import Tools&lt;br /&gt;
 [[Code 01060]] Searching Improvements&lt;br /&gt;
 [[Code 01070]] Tagging for various content-types&lt;br /&gt;
 [[Code 01080]] User Registration and Management&lt;br /&gt;
&lt;br /&gt;
== Libraries/Framework related ==&lt;br /&gt;
&lt;br /&gt;
 [[Code 02000]] MultiDB support&lt;br /&gt;
 [[Code 02010]] Create an PHP API for using mootools.&lt;br /&gt;
&lt;br /&gt;
== Modules ==&lt;br /&gt;
&lt;br /&gt;
 [[Code 03000]]&lt;br /&gt;
 [[Code 03010]]&lt;br /&gt;
&lt;br /&gt;
== Templates ==&lt;br /&gt;
&lt;br /&gt;
 [[Code 04000]] Deploy Triplify for Joomla! v 1.5, Semantic Web&lt;br /&gt;
 [[Code 04010]] Semantic Web: Linked Data&lt;br /&gt;
&lt;br /&gt;
== Unit testing ==&lt;br /&gt;
&lt;br /&gt;
 [[Code 05000]] Improve Unit Test Coverage&lt;br /&gt;
 [[Code 05010]] Create Web-Based Unit Test Runner&lt;br /&gt;
&lt;br /&gt;
== Plugins ==&lt;br /&gt;
&lt;br /&gt;
 [[Code 06000]] Comments; threaded and not threaded, support for various content-types, not just articles&lt;br /&gt;
 [[Code 06010]] SEF URL Plugins&lt;br /&gt;
 [[Code 06020]] Create a plugin for TinyMCE that makes it easy for end users to choose which add-ons they want without hacking the core&lt;br /&gt;
&lt;br /&gt;
== Inter-Project Projects ==&lt;br /&gt;
&lt;br /&gt;
 [[Code 08001]]  Civicrm integration&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
 [[Code 07000]] Multi-lingual support&lt;br /&gt;
 [[Code 07010]] Error Page Handling&lt;br /&gt;
 [[Code 07020]] Data Portability&lt;br /&gt;
 [[Code 07030]] Facebook Integration&lt;br /&gt;
 [[Code 07040]] Create an download extension for Joomla! &lt;br /&gt;
 [[Code 07050]] Create an extension to register Joomla! tasks/projects&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Google Summer of Code 2008]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Archived:Code_05000&amp;diff=3593</id>
		<title>Archived:Code 05000</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Archived:Code_05000&amp;diff=3593"/>
		<updated>2008-03-20T12:00:39Z</updated>

		<summary type="html">&lt;p&gt;Instance: New page: == Title == Improve Unit Test Coverage  == One Line Summary == Most of the code in &amp;quot;Joomla!&amp;quot; doesn&amp;#039;t have supporting unit tests, this project aims to address that.  == Description == The v...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Title ==&lt;br /&gt;
Improve Unit Test Coverage&lt;br /&gt;
&lt;br /&gt;
== One Line Summary ==&lt;br /&gt;
Most of the code in &amp;quot;Joomla!&amp;quot; doesn&#039;t have supporting unit tests, this project aims to address that.&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
The value of unit tests increase exponentially with the amount of code that is covered by tests. This project involves identifying code that doesn&#039;t have existing unit tests and writing them.&lt;br /&gt;
&lt;br /&gt;
== Skills needed ==&lt;br /&gt;
&lt;br /&gt;
== Difficulty ==&lt;br /&gt;
&lt;br /&gt;
== Work Product ==&lt;br /&gt;
&lt;br /&gt;
== Licensing ==&lt;br /&gt;
All code must be created using the [[http://www.gnu.org/licenses/old-licenses/gpl-2.0.html#SEC4 GNU General Public License version]]&lt;br /&gt;
&lt;br /&gt;
Documentation written for this task must be made available under the Joomla! Electronic Documentation License. &lt;br /&gt;
&lt;br /&gt;
== Possible mentor ==&lt;br /&gt;
&lt;br /&gt;
Return to [[Google Summer of Code 2008]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Google Summer of Code 2008]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=3123</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=3123"/>
		<updated>2008-03-05T12:35:13Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Unit Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For a good general discussion of unit testing, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in /testing/branches/2007-12-17. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
--class-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--debug&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
--help&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
--sequence-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--test-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing simple stubs that emulate the code unit&#039;s environment. These stubs are known as &amp;quot;Mock Objects&amp;quot;. Mock objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]].&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with Selenium, a browser based test automation tool.&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=3122</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=3122"/>
		<updated>2008-03-05T12:31:36Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* The Testing Hierarchy: Unit, Subsystem, Integrated */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For more information, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article on unit testing].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in /testing/branches/2007-12-17. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
--class-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--debug&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
--help&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
--sequence-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--test-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing simple stubs that emulate the code unit&#039;s environment. These stubs are known as &amp;quot;Mock Objects&amp;quot;. Mock objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]].&lt;br /&gt;
&lt;br /&gt;
=== The Testing Hierarchy: Unit, Subsystem, Integrated ===&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with Selenium, a browser based test automation tool.&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=3121</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=3121"/>
		<updated>2008-03-05T12:30:50Z</updated>

		<summary type="html">&lt;p&gt;Instance: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For more information, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article on unit testing].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in /testing/branches/2007-12-17. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
--class-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--debug&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
--help&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
--sequence-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--test-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing simple stubs that emulate the code unit&#039;s environment. These stubs are known as &amp;quot;Mock Objects&amp;quot;. Mock objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests: [[Unit_Testing_--_a_Simple_Example|Simple Example]], [[Unit_Testing_--_Data_Driven_Example|Data Driven Example]], [[Unit_Testing_--_Plugin_Example|Plugin Example]].&lt;br /&gt;
&lt;br /&gt;
==== The Testing Hierarchy: Unit, Subsystem, Integrated ====&lt;br /&gt;
Software testing systems usually run through a spectrum from &amp;quot;pure&amp;quot; unit tests through to fully integrated systems tests. We&#039;ve described low level unit tests above. Integrated testing typically involves some sort of script that simulates user actions and then verifies that the result matches what&#039;s expected. This sort of &amp;quot;end to end&amp;quot; test verifies that all parts of the system are working correctly.&lt;br /&gt;
&lt;br /&gt;
It&#039;s unfortunate that there is no clear nomenclature to describe all the intermediate stages of testing. The next stage beyond testing a single unit of code is subsystem testing. A subsystem test verifies that two or more units of code are interacting correctly to produce the desired result. In the simplest case, a subsystem test can be created simply by replacing mock objects with real objects and running unit tests on the top level module. In practise, this tends to not work as well as expected, because the original unit test data wasn&#039;t designed for a subsystem test, or because the nature of the test cases needs to be changed in order to fully test the subsystem. After all there is little point in simply repeating the unit test cases; the objective of a subsystem test should be to test boundary conditions and special cases that would be difficult to duplicate in unit tests.&lt;br /&gt;
&lt;br /&gt;
Once a subsystem has been tested, it can be integrated into a larger system, which is still a subset of the whole product. Tests can be written for larger and larger subsystems, but at each stage the complexity of the tests increases. At some point, the effort required to hand craft tests exceeds the benefits of running them. This is where integrated testing comes in.&lt;br /&gt;
&lt;br /&gt;
Integrated testing involves recording a user&#039;s interaction with the system into a script that can be replayed. The testing framework then compares the system&#039;s response with the expected response and passes or fails the test. The PHPUnit testing framework that we use has the ability to work with Selenium, a browser based test automation tool.&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing_Example_Simple&amp;diff=3120</id>
		<title>Unit Testing Example Simple</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing_Example_Simple&amp;diff=3120"/>
		<updated>2008-03-05T11:53:46Z</updated>

		<summary type="html">&lt;p&gt;Instance: Unit Testing Example Simple moved to Unit Testing -- a Simple Example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Unit Testing -- a Simple Example]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=3107</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=3107"/>
		<updated>2008-03-04T21:26:53Z</updated>

		<summary type="html">&lt;p&gt;Instance: Information on running and writign tests&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For more information, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article on unit testing].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in /testing/branches/2007-12-17. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
--class-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--debug&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
--help&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
--sequence-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--test-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;br /&gt;
&lt;br /&gt;
==== Writing Unit Tests ====&lt;br /&gt;
At risk of stating the obvious, in the &amp;quot;purest&amp;quot; case the purpose of a unit test is to &#039;&#039;isolate a unit of code from its environment and to test the operation of that code&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
This isolation is usually achieved by writing simple stubs that emulate the code unit&#039;s environment. These stubs are known as &amp;quot;Mock Objects&amp;quot;. Mock objects can be passive, by simply simulating the environment, or they can be more active, keeping track of how they are being used by the test unit and reporting any variations from the expected behaviour.&lt;br /&gt;
&lt;br /&gt;
An interesting aspect of writing tests is that they become &#039;&#039;de facto&#039;&#039; detailed technical specifications of the interfaces between units of code. The fact that these specifications can be verified in an automated way makes them a superb resource when refactoring code.&lt;br /&gt;
&lt;br /&gt;
The test code has a few templates designed to kick-start a test. They are:&lt;br /&gt;
&lt;br /&gt;
/unittest/sample-datatest-php.txt&lt;br /&gt;
/unittest/sample-simpletest.php.txt&lt;br /&gt;
&lt;br /&gt;
Here are some example tests [[Unit_Testing_Example_Simple]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=3106</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=3106"/>
		<updated>2008-03-04T20:29:49Z</updated>

		<summary type="html">&lt;p&gt;Instance: Add running tests section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For more information, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article on unit testing].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in /testing/branches/2007-12-17. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;br /&gt;
&lt;br /&gt;
==== Running Unit Tests ====&lt;br /&gt;
Test files follow the form class-sequence-type-test.php, for example JObject-0000-class-test.php. For tests that are not class based, the first element refers to the object being tested. An example of this is the e-mail cloaking plugin test, which is called emailcloak-0000-mode1-test.php.&lt;br /&gt;
&lt;br /&gt;
Joomla unit tests use a customized test &amp;quot;runner&amp;quot;. Every test directory should have a &amp;quot;runtests.php&amp;quot; file. Runtests has a few options, mostly to allow the selection of specific tests. The command line options are:&lt;br /&gt;
&lt;br /&gt;
--class-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
e.g. --class-filter /JDate/ Selects only tests that have a class part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--debug&lt;br /&gt;
&lt;br /&gt;
Turns on additional debugging output.&lt;br /&gt;
&lt;br /&gt;
--help&lt;br /&gt;
&lt;br /&gt;
Prints information on options and exits.&lt;br /&gt;
&lt;br /&gt;
--sequence-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a sequence part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
--test-filter &#039;&#039;regex&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Selects only tests that have a test part that matches the regular expression.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TODO:&#039;&#039;&#039; Expand command line parsing to add other features of the PHPUnit framework, such as output formats, code metrics reports, etc.&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=3105</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=3105"/>
		<updated>2008-03-04T20:14:13Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Current Work */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For more information, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article on unit testing].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in /testing/branches/2007-12-17. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* There is no longer any need to patch the main code to enable unit tests.&lt;br /&gt;
* Basic techniques for mock objects are defined.&lt;br /&gt;
* Strategies for dealing with local configuration is not yet complete, but there is a plan.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=2289</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=2289"/>
		<updated>2008-01-22T19:49:52Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Unit Testing in Joomla! */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For more information, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article on unit testing].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to move to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in /testing/branches/2007-12-17. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* The PHPUnit tests require a small modification to the code before they run. /libraries/loader.php requires a conditional &amp;quot;if (! function_exists(&#039;jimport&#039;))&amp;quot; wrapper around the jimport() function.&lt;br /&gt;
* Strategies for dealing with local configuration and mock objects are not yet complete.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=2288</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=2288"/>
		<updated>2008-01-22T19:49:03Z</updated>

		<summary type="html">&lt;p&gt;Instance: /* Unit Testing in Open Source */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For more information, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article on unit testing].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects, with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to mofe to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in /testing/branches/2007-12-17. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* The PHPUnit tests require a small modification to the code before they run. /libraries/loader.php requires a conditional &amp;quot;if (! function_exists(&#039;jimport&#039;))&amp;quot; wrapper around the jimport() function.&lt;br /&gt;
* Strategies for dealing with local configuration and mock objects are not yet complete.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=2286</id>
		<title>Unit Testing</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Unit_Testing&amp;diff=2286"/>
		<updated>2008-01-22T19:48:23Z</updated>

		<summary type="html">&lt;p&gt;Instance: Initial description of unit test as it applies to Joomla!&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Unit Testing ==&lt;br /&gt;
Unit testing is an essential part of a good Quality Control program.&lt;br /&gt;
For more information, visit the [http://en.wikipedia.org/wiki/Unit_test Wikipedia article on unit testing].&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Open Source ===&lt;br /&gt;
Open source projects with multiple developers working in parallel around the world, can greatly benefit from unit testing. The main benefits are:&lt;br /&gt;
* Unit tests help highlight cases where seemingly minor changes cause unexpected breakage.&lt;br /&gt;
* Unit tests help clearly specify how a class should behave.&lt;br /&gt;
* Unit tests can expose design flaws very early in development.&lt;br /&gt;
* Unit tests make great examples. They are a great place for developers to learn how to use the code.&lt;br /&gt;
&lt;br /&gt;
=== Unit Testing in Joomla! ===&lt;br /&gt;
Unit testing capabilities in Joomla are still at an early stage. The intention is to define more standards for developing tests, and then to expand the scope of available tests&lt;br /&gt;
&lt;br /&gt;
The SVN repository contains code under the /testing path. /testing/trunk contains code based on the SimpleTest framework. In early December 2007, the development team elected to mofe to the [http://www.phpunit.de PHPUnit] framework.&lt;br /&gt;
&lt;br /&gt;
Work on using PHPUnit has been done in /testing/branches/2007-12-17. Some new tests have been added, many old tests from the SimpleTest days are completely broken.&lt;br /&gt;
&lt;br /&gt;
At this point, PHPUnit based tests only run in a command line environment.&lt;br /&gt;
&lt;br /&gt;
==== Current Work ====&lt;br /&gt;
* The PHPUnit tests require a small modification to the code before they run. /libraries/loader.php requires a conditional &amp;quot;if (! function_exists(&#039;jimport&#039;))&amp;quot; wrapper around the jimport() function.&lt;br /&gt;
* Strategies for dealing with local configuration and mock objects are not yet complete.&lt;br /&gt;
* Files of the form class-sequence-type-test.php, for example JObject-0000-class-test.php use PHPUnit.&lt;br /&gt;
* The JDate tests present a good example of a data-driven test, but they won&#039;t run on the current 1.5 code base (there are some proposed API changes as a result of unit test development).&lt;br /&gt;
* Previously functional tests, such as JFTP, haven&#039;t been moved to the PHPUnit environment yet.&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=JDOC:Creating_pages_with_preloaded_text&amp;diff=2247</id>
		<title>JDOC:Creating pages with preloaded text</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=JDOC:Creating_pages_with_preloaded_text&amp;diff=2247"/>
		<updated>2008-01-22T13:53:38Z</updated>

		<summary type="html">&lt;p&gt;Instance: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;messagebox&amp;quot;&amp;gt;&lt;br /&gt;
&#039;&#039;Please note: Some techniques recommended in this article require the use of extensions.  Please use with care.  The status assigned to each extension is self-assigned by the maintainer and does not represent the opinion of the MediaWiki development team.&#039;&#039;&lt;br /&gt;
----&lt;br /&gt;
This article is based on [[Mediawiki:Manual:Creating_pages_with_preloaded_text]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Preloading wikitext&#039;&#039;&#039; is one of many techniques for helping users create pages more quickly and for improving the quality of those pages.  Instead of creating a new page from scratch, users are presented with a partially created page, and possibly instructions for filling it in.&lt;br /&gt;
&lt;br /&gt;
This technique is especially useful when:&lt;br /&gt;
* wiki users are willing to read and write simple wikitext (sometimes an issue on intranet installations of MediaWiki)&lt;br /&gt;
* the wiki contains one or more categories of articles with lots of pro-forma text&lt;br /&gt;
* the information that needs to be collected for such articles is a mix of structured data and free form text&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Creating pages with preloaded text is a three step process:&lt;br /&gt;
# Design the preload file and its supporting templates&lt;br /&gt;
# Create pages for the preload files and supporting templates&lt;br /&gt;
# Set up the trigger to load the preload file&lt;br /&gt;
&lt;br /&gt;
== Designing the preload file ==&lt;br /&gt;
The preload file is often an article with an embedded template. For example, if you wanted one article for each customer or marketing contact, you might want to preload text that looks something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   &amp;lt;!-- Please enter your customer&#039;s contact information after the equal sign.&lt;br /&gt;
        If you need help uploading the business card images, please see&lt;br /&gt;
        [[Help:Uploading business card images]] &lt;br /&gt;
   --&amp;gt;&lt;br /&gt;
   {{CustomerContact&lt;br /&gt;
   |Number=&lt;br /&gt;
   |BizcardImage=&lt;br /&gt;
   |Primary phone number=&lt;br /&gt;
   |Address=&lt;br /&gt;
   }}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Naming and documenting the preload file ==&lt;br /&gt;
Some extensions (see [[mediawiki:Extension:Boilerplate]]) have specific expectations as to where the preloaded text should be stored.  Others leave that decision entirely up to the system administrator.&lt;br /&gt;
&lt;br /&gt;
Naming and documenting the preload file takes some care because preload files don&#039;t always show up on &amp;quot;What links here&amp;quot; and so are at risk for accidental deletion (no info/no links - hard to tell from an article that got created and abandoned). &lt;br /&gt;
For template based preload files, the following naming conventions may help avoid accidental deletion:&lt;br /&gt;
&lt;br /&gt;
* place template in &amp;lt;code&amp;gt;Template:&#039;&#039;CategoryName&#039;&#039;&amp;lt;/code&amp;gt;&lt;br /&gt;
* place preload file in &amp;lt;code&amp;gt;Template:&#039;&#039;CategoryName&#039;&#039;/Preload&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While documentation of regular templates is often presented on the template page itself (using noinclude tags), this is not possible for a page to be preloaded. Also categories and interlanguage links for the preload page itself are not possible without affecting the wikitext that is preloaded. The talk page has to be used for all these.&lt;br /&gt;
&lt;br /&gt;
== Loading the preload file ==&lt;br /&gt;
&lt;br /&gt;
Preloading can be done with a preload parameter in a URL like&lt;br /&gt;
{{fullurl:Joomla:Sandbox/Preloadtest|action=edit&amp;amp;preload=Template:Preload_demo}} which links to the edit box of a new page, preloaded with {{tim|Preload demo}}. There are also a number of extensions available to trigger your preload file, see below.&lt;br /&gt;
&lt;br /&gt;
The wikitext of the source page, &#039;&#039;&#039;including noinclude parts and tags, but not includeonly tags&#039;&#039;&#039;, is preloaded into the editbox if the page or section does not exist yet. If the page or section to be edited already exists then only its wikitext is loaded, the preload command is ignored.&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* Both the &amp;amp;lt;noinclude&amp;gt; and &amp;amp;lt;/noinclude&amp;gt; tags AND their content are preloaded, which means you can&#039;t categorize the source page or include some self-documentation: it&#039;d be dumped into the preloaded text too.&lt;br /&gt;
* The &amp;amp;lt;includeonly&amp;gt; and &amp;amp;lt;/includeonly&amp;gt; tags are stripped from the source page. If you need the preloaded text to provide includeonly tags, you can use&lt;br /&gt;
::&amp;lt;CODE&amp;gt;&amp;amp;lt;include&amp;amp;lt;includeonly&amp;gt;&amp;amp;lt;/includeonly&amp;gt;only&amp;gt;&amp;lt;/CODE&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:in your source: since the two middle tags will be stripped, the preloaded text will end up with just the &amp;amp;lt;includeonly&amp;gt; wanted.&lt;br /&gt;
&lt;br /&gt;
Thus there is neither a complete inclusion nor a regular transclusion. See also [http://bugzilla.wikimedia.org/show_bug.cgi?id=5210 bug 5210] (since 2006-03-09).&lt;br /&gt;
&lt;br /&gt;
== Extensions ==&lt;br /&gt;
Extensions that trigger a preload file include:&lt;br /&gt;
&lt;br /&gt;
* [[Mediawiki:Extension:Inputbox]], [[Mediawiki:Extension:CreateBox]], [[Mediawiki:Extension:CreateArticle]] offer the most control over the loading process.  Each of these extensions let you place a button somewhere in an article, typically in a user help page or the category page corresponding to the article.  You specify the name of the preload file as part of the button definition.&lt;br /&gt;
* [[Mediawiki:Extension:BoilerplateSelection]] - preloaded text selected by pattern matching on article title.  To set this up you create an array in [[Joomla:LocalSettings.php]] file.  This array associates regular expressions with preload article names. &lt;br /&gt;
* [[Mediawiki:Extension:Boilerplate]] - preloaded text for all articles irrespective of name or category.  The preloaded text must be stored in the MediaWiki article &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[Mediawiki:MediaWiki:Boilerplate]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.  It will be loaded automatically whenever an article is created.&lt;br /&gt;
&lt;br /&gt;
A few extensions also handle all three steps for you:&lt;br /&gt;
&lt;br /&gt;
* [[Mediawiki:Extension:Add Article to Category]] - puts an add-an-article button on each category.  When an article is created using this extension it will automatically contain the wiki text for including the article in that category, i.e. &amp;lt;nowiki&amp;gt;[[Category:...]]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Template documentation|preload]]&lt;br /&gt;
[[Category:Wiki Templates|preload]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=JDOC:Templates_for_chunk_categorisation&amp;diff=2246</id>
		<title>JDOC:Templates for chunk categorisation</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=JDOC:Templates_for_chunk_categorisation&amp;diff=2246"/>
		<updated>2008-01-22T13:52:36Z</updated>

		<summary type="html">&lt;p&gt;Instance: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;On this page you will find a bunch of &#039;&#039;Wiki templates&#039;&#039; to help categorize your content according to the information provided in the article &amp;quot;[[Categorising a chunk]]&amp;quot;. Unlike Joomla! templates, Wiki templates are wiki &#039;&#039;pages&#039;&#039; which can be used in other pages. They reside in their own content &#039;&#039;namespace&#039;&#039; to avoid name clashing with regular articles. In order to use such a Template, all you have to do is to enclose its name in &#039;&#039;curly brackets&#039;&#039;: &amp;lt;nowiki&amp;gt;{{template name}}&amp;lt;/nowiki&amp;gt;. That&#039;s it.&lt;br /&gt;
&lt;br /&gt;
The list of available templates will be expanded in the future.&lt;br /&gt;
&lt;br /&gt;
== Chunks ==&lt;br /&gt;
[[Category:Wiki Templates]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=JDOC:Local_wiki_templates&amp;diff=2245</id>
		<title>JDOC:Local wiki templates</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=JDOC:Local_wiki_templates&amp;diff=2245"/>
		<updated>2008-01-22T13:51:50Z</updated>

		<summary type="html">&lt;p&gt;Instance: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p style=&amp;quot;text-align:center;border:1px solid #ccc&amp;quot;&amp;gt;[[Local wiki templates]] &amp;amp;bull; [[Local wiki extensions]] &amp;amp;bull; [[Local interwiki links]]&amp;lt;/p&amp;gt;&lt;br /&gt;
MediaWiki templates should not to be confused with Joomla! templates!  MediaWiki templates are &amp;quot;boiler-plate&amp;quot; items that can be included in your wiki pages by inserting a simple reference.&lt;br /&gt;
&lt;br /&gt;
===Incomplete Content Notice===&lt;br /&gt;
Insert &amp;lt;nowiki&amp;gt;{{Content-incomplete}}&amp;lt;/nowiki&amp;gt; to obtain the following notice:&lt;br /&gt;
{{Content-incomplete}}&lt;br /&gt;
&lt;br /&gt;
===Standard License Notice===&lt;br /&gt;
Insert {{tl|license}} to obtain the following notice:&lt;br /&gt;
&lt;br /&gt;
{{license}}&lt;br /&gt;
&lt;br /&gt;
===Page In Use Notice===&lt;br /&gt;
Insert {{tl|inuse}} to obtain the following notice:&lt;br /&gt;
{{inuse}}&lt;br /&gt;
&lt;br /&gt;
===Under Construction Notice===&lt;br /&gt;
Insert {{tl|underconstruction}} to obtain the following notice:&lt;br /&gt;
{{underconstruction}}&lt;br /&gt;
&lt;br /&gt;
===Article Reviews===&lt;br /&gt;
Once you&#039;re done with editing please replace {{tl|underconstruction}} and {{tl|inuse}} with {{tl|review}}. This will add your document to the [[:Category:Under review]].&lt;br /&gt;
{{review}}&lt;br /&gt;
&lt;br /&gt;
==Table of Contents==&lt;br /&gt;
You will get a table of contents box on each page by default as soon as you start making use of headings and subheadings on the page.  The default table of contents box is located on the left and text does not flow around it.  You can make the table of contents box float right by inserting &#039;&#039;&#039;{{tlp|RightTOC}}&#039;&#039;&#039; at the appropriate place in your page.  You can also suppress the table of contents box altogether by inserting &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;__NOTOC__&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039; at the top of the page.&lt;br /&gt;
&lt;br /&gt;
==Shortcuts, Links &amp;amp;amp; Navigation==&lt;br /&gt;
Some URLs can become utterly long, some are ugly, and some are just tedious to type over and over again. Adding categories to a page can become equally annoying. &lt;br /&gt;
&lt;br /&gt;
To simplify your job try some of the following templates. Similar to the interwikis, they&#039;re true keystroke-savers:&lt;br /&gt;
* {{tlx|jsite|keyword}}, for example:&lt;br /&gt;
: &amp;lt;nowiki&amp;gt;{{jsite}}&amp;lt;/nowiki&amp;gt; = {{jsite}}&lt;br /&gt;
: &amp;lt;nowiki&amp;gt;{{jsite|forum}}&amp;lt;/nowiki&amp;gt; = {{jsite|forum}}&lt;br /&gt;
: &amp;lt;nowiki&amp;gt;{{jsite|ext}}&amp;lt;/nowiki&amp;gt; = {{jsite|ext}}. For more see {{tl|jsite}}.&lt;br /&gt;
* {{tlx|jforum|keyword}}, shortcuts for the many Working Group fora, i.e.&lt;br /&gt;
: &amp;lt;nowiki&amp;gt;{{jforum}}&amp;lt;/nowiki&amp;gt; = {{jforum}}&lt;br /&gt;
: &amp;lt;nowiki&amp;gt;{{jforum|doc}}&amp;lt;/nowiki&amp;gt; = {{jforum|doc}}&lt;br /&gt;
: &amp;lt;nowiki&amp;gt;{{jforum|devdoc}}&amp;lt;/nowiki&amp;gt; = {{jforum|devdoc}}. For more see {{tl|jforum}}.&lt;br /&gt;
&lt;br /&gt;
: an excerpt of categorisation and [[:Category:Typing-aid templates|typing-aid templates]] coming soon! --[[User:CirTap|CirTap]] 14:52, 20 January 2008 (EST)&lt;br /&gt;
&lt;br /&gt;
[[Category:Wiki Templates]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Category:License_templates&amp;diff=2244</id>
		<title>Category:License templates</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Category:License_templates&amp;diff=2244"/>
		<updated>2008-01-22T13:50:37Z</updated>

		<summary type="html">&lt;p&gt;Instance: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Wiki Templates]]&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Template:Catjoomla/doc&amp;diff=2242</id>
		<title>Template:Catjoomla/doc</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Template:Catjoomla/doc&amp;diff=2242"/>
		<updated>2008-01-22T13:48:48Z</updated>

		<summary type="html">&lt;p&gt;Instance: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This template is a categorisation workhorse. It adds a page to several categories at once and supports supplemental text to abandon features that have been deprecated or removed from the Joomla! code base, the {{jf}}, or any of its [[Application]]s. Although it&#039;s best applied to {{jfr}} pages it&#039;s also a valuable addition in other types of Joomla! documentation.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
For example in articles about a concept or feature as well as in a [[:Category|Tutorial|]]:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{catjoomla|1.5.0}}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Framework or feature specific:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{catjoomla&lt;br /&gt;
| since      = version&lt;br /&gt;
| package    = name&lt;br /&gt;
| class      = name&lt;br /&gt;
| deprecated = version&lt;br /&gt;
|   use      = pagename&lt;br /&gt;
| removed    = version&lt;br /&gt;
|   remark   = wiki text&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;big&amp;gt;All &amp;lt;tt&amp;gt;version&amp;lt;/tt&amp;gt; numbers MUST use the &#039;&#039;&#039;major.minor.release&#039;&#039;&#039; numbering scheme, ie. &amp;lt;tt&amp;gt;1.5.0&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;1.0.12&amp;lt;/tt&amp;gt; etc.&amp;lt;/big&amp;gt; &lt;br /&gt;
&amp;lt;br /&amp;gt;Don&#039;t drop the &#039;&#039;.release&#039;&#039; number just because you don&#039;t know the exact version. You may look at Joomla!s CHANGELOG.php however. &lt;br /&gt;
If you are unsure about the exact version number a feature was introduced please ommit the &amp;lt;var&amp;gt;since&amp;lt;/var&amp;gt; parameter alltogether, and &#039;&#039;don&#039;t&#039;&#039; add the unnamed 1. parameter as shown in the general syntax. This will place the document in the &amp;quot;unknown version&amp;quot; category where someone who &#039;&#039;does know&#039;&#039; can find the entry and possibly fix it.&lt;br /&gt;
;since (or &amp;lt;nowiki&amp;gt;{{{1}}}&amp;lt;/nowiki&amp;gt;)&lt;br /&gt;
: Joomla! Version this feature was first introduced&lt;br /&gt;
;package&lt;br /&gt;
: Framework package name&lt;br /&gt;
:;class&lt;br /&gt;
:: Class name, can only be used if &#039;&#039;package&#039;&#039; name is given&lt;br /&gt;
;deprecated&lt;br /&gt;
: Joomla! Version the feature was deprecated&lt;br /&gt;
:;use&lt;br /&gt;
:: if &#039;&#039;deprecated&#039;&#039; is set, the page name of the replacing (new, alternative) feature, if applicable. See &#039;&#039;remark&#039;&#039; parameter.&lt;br /&gt;
;removed&lt;br /&gt;
: Joomla! Version the feature was removed (w/o adequated replacement)&lt;br /&gt;
;remark:&lt;br /&gt;
: Supplemental message, i.e. combined with &#039;&#039;removed&#039;&#039;. ;This parameter may contain wiki text.&lt;br /&gt;
You cay &amp;quot;misuse&amp;quot; the &#039;&#039;remark&#039;&#039; parameter to apply additional categories not covered in the default set.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
Documentation in a deprecated feature:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;catjoomla&lt;br /&gt;
 &amp;amp;#x7C; since      = 1.5.0&lt;br /&gt;
 &amp;amp;#x7C; package    = Whatever&lt;br /&gt;
 &amp;amp;#x7C; class      = JWhatever&lt;br /&gt;
 &amp;amp;#x7C; deprecated = 1.6.0&lt;br /&gt;
 &amp;amp;#x7C; use        = [[JAPI:Newpackage/JWhatelse]]&lt;br /&gt;
 }}&lt;br /&gt;
will assign the page to the following categories&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;Framework, Whatever, JWhatever, Joomla! 1.5.0, Joomla! 1.6.0&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
and generate this text:&lt;br /&gt;
 Deprecated as of &amp;lt;nowiki&amp;gt;[[Framework:Joomla! 1.6.0]]&amp;lt;/nowiki&amp;gt;. Please use &amp;lt;nowiki&amp;gt;[[JAPI:Newpackage/JWhatelse|]]&amp;lt;/nowiki&amp;gt; instead.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;{{&amp;lt;/nowiki&amp;gt;catjoomla&lt;br /&gt;
 &amp;amp;#x7C; since   = 1.0.6&lt;br /&gt;
 &amp;amp;#x7C; removed = 1.6.0&lt;br /&gt;
 &amp;amp;#x7C; remark = No alternative at time of writing.&lt;br /&gt;
 }}&lt;br /&gt;
&lt;br /&gt;
== Issues ==&lt;br /&gt;
You can&#039;t use the literal pipe character in &#039;&#039;&#039;any&#039;&#039;&#039; parameter, i.e. to rename the link. A trailing &amp;lt;tt&amp;gt;|&amp;lt;/tt&amp;gt; pipe is automatically added after the &#039;&#039;&#039;page name&#039;&#039;&#039; assigned to &amp;lt;tt&amp;gt;&amp;lt;nowiki&amp;gt;{{{use}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt;. You may however try the {{tlp|!}} template instead.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;tt&amp;gt;&amp;lt;nowiki&amp;gt;{{{use}}}&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt; is refering to a subpage via &amp;lt;tt&amp;gt;/Pagename/&amp;lt;/tt&amp;gt; (note the trailing &amp;lt;tt&amp;gt;/&amp;lt;/tt&amp;gt;), the link caption might look wrong but the link itself should work (provided the target page exists). This is hopefully going to be fixed soon.&lt;br /&gt;
&lt;br /&gt;
Using the &#039;&#039;&#039;[[Help:ParserFunctions|#titleparts:]&#039;&#039;&#039; parser function instead of, or in combination with, the named parameters, is should be easier to place a subpage such as &amp;quot;Package/Application/Classes/JApplication&amp;quot; into all appropriate categories with a suitable sortorder key.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See also:&#039;&#039;&#039; &lt;br /&gt;
* {{tlp|future}} to &amp;quot;flag&amp;quot; a feature of a future, yet unreleased version of Joomla! ... if you dare ;)&lt;br /&gt;
&amp;lt;includeonly&amp;gt;[[Category:Wiki Templates|{{PAGENAME}}]][[Category:Link templates|{{PAGENAME}}]]&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>Instance</name></author>
	</entry>
</feed>