Archived

Difference between revisions of "How to override the output from the Joomla! core"

From Joomla! Documentation

(Marked this version for translation)
(16 intermediate revisions by 9 users not shown)
Line 1: Line 1:
There may be occasions where you would like to change the way a Joomla! Extension (such as a Component or Module, whether from the Joomla! core or produced by a third party) is displayed on your site.  Of course, you could recode the Extension from scratch, but that may be a bit ambitious for you! Thankfully, there is another way.   
+
<noinclude><languages /></noinclude>
 +
<translate>
 +
<!--T:1-->
 +
There may be occasions where you would like to change the way a Joomla! Extension (such as a Component or Module, whether from the Joomla! core or produced by a third party) is displayed on your site.  Of course, you could recode the Extension from scratch, but that may be a bit ambitious for you! Thankfully, there is another way.
 +
</translate>  
  
 +
<translate>
 +
<!--T:2-->
 
The standard output from any Joomla! Module or Component can be overridden by adding code to the <code>html</code> directory of your template. It is also possible to override two aspects of core functionality: Module chrome, and pagination.
 
The standard output from any Joomla! Module or Component can be overridden by adding code to the <code>html</code> directory of your template. It is also possible to override two aspects of core functionality: Module chrome, and pagination.
 +
</translate>
  
=== Getting a head-start with overrides ===
+
<translate>
If you are new to Joomla! development, then it is probably easiest to start with an existing view, and try modifying it to get what you want. To do this, you should make a copy of the existing view in the <code>html</code> directory of your template, and then modify the copy.
+
<!--T:3-->
 +
As of {{JVer|3.2}} overrides can be created using the Template manager [[s:MyLanguage/J3.2:How to use the Template Manager#Creating_Overrides|Creating Overrides]]
 +
</translate>
  
[http://docs.joomla.org/Understanding_Output_Overrides Tutorial]
+
<translate>== Getting a head-start with overrides == <!--T:4--></translate>
 +
<translate>
 +
<!--T:5-->
 +
If you are new to Joomla! development, then it is probably easiest to start with an existing view, and try modifying it to get what you want.  To do this, you should make a copy of the existing view in the <code>html</code> directory of your template, and then modify the copy.
 +
</translate>
  
The directory structure you need is:<br/>
+
<translate><!--T:6-->
 +
The directory structure you need is:</translate>
 +
<br/>
 
<source lang="xml">TEMPLATE_NAME/html/EXTENSION_NAME/VIEW_NAME/FILE_NAME.php</source>
 
<source lang="xml">TEMPLATE_NAME/html/EXTENSION_NAME/VIEW_NAME/FILE_NAME.php</source>
  
For example, if you want to change the way that the '<code>Article</code>' view displays a <code>com_content</code> article, then you should copy the file at  
+
<translate>
 +
<!--T:7-->
 +
For example, if you want to change the way that the '<code>Article</code>' view displays a <code>com_content</code> article, then you should copy the file at :
 +
</translate>
  
 
<source lang="xml">
 
<source lang="xml">
 
PATH_TO_JOOMLA/components/com_content/views/article/tmpl/default.php
 
PATH_TO_JOOMLA/components/com_content/views/article/tmpl/default.php
to
+
<translate><!--T:8-->
 +
to</translate>
 
TEMPLATE_NAME/html/com_content/article/default.php
 
TEMPLATE_NAME/html/com_content/article/default.php
 
</source>
 
</source>
  
 +
<translate>
 +
<!--T:9-->
 
(note the slight difference in directory structure)
 
(note the slight difference in directory structure)
 +
</translate>
  
Similarly, if you want to change how the <code>mod_login</code> Module is displayed, then you should copy  
+
<translate>
 +
<!--T:10-->
 +
Similarly, if you want to change how the <code>mod_login</code> Module is displayed, then you should copy :
 +
</translate>
  
 
<source lang="xml">
 
<source lang="xml">
 
PATH_TO_JOOMLA/modules/mod_login/tmpl/default.php
 
PATH_TO_JOOMLA/modules/mod_login/tmpl/default.php
to
+
<translate><!--T:11-->
 +
to</translate>
 
TEMPLATE_NAME/html/mod_login/default.php
 
TEMPLATE_NAME/html/mod_login/default.php
 
</source>
 
</source>
  
 +
<translate>
 +
<!--T:12-->
 +
Joomla! comes pre-packaged with a frontend template called [[Beez]]. Beez utilizes template overrides to produce a table-less layout for faster, smoother, and semantically correct markup. To see how it's done, locate your Joomla! installation's <code>template</code> directory, and you'll notice the Beez template. Inside the Beez template directory, you'll find a directory named <code>html</code>.
 +
</translate>
  
Joomla! comes pre-packaged with a frontend template called [[Beez]]. Beez utilizes template overrides to produce a table-less layout for faster, smoother, and semantically correct markup. To see how it's done, locate your Joomla! installation's <code>template</code> directory, and you'll notice the Beez template. Inside the Beez template directory, you'll find a directory named <code>html</code>  
+
<translate><!--T:13-->
 
+
The entire directory structure is as follows:</translate>
the entire directory structure is as follows:  
+
 
<source lang="xml">/your_joomla/templates/Beez/html/</source>
 
<source lang="xml">/your_joomla/templates/Beez/html/</source>
  
 +
<translate><!--T:23-->
 
If you want to try modifying the overrides used in Beez, you could simply copy and paste the Beez <code>html</code> directory into your own template's main directory.  
 
If you want to try modifying the overrides used in Beez, you could simply copy and paste the Beez <code>html</code> directory into your own template's main directory.  
However you choose to make your override files, you will need to ensure that they are correctly installed with your template.  To do this, you should add the following code to your template's <code>templateDetails.xml</code> file (in between the <code><files></code> and <code></files></code> tags):
+
However you choose to make your override files, you will need to ensure that they are correctly installed with your template.  To do this, you should add the following code to your template's <code>templateDetails.xml</code> file (in between the <code><files></code> and <code></files></code> tags):</translate>
  
 
<source lang="xml">
 
<source lang="xml">
Line 42: Line 73:
 
</source>
 
</source>
  
The above code in essence lets the Joomla! [[Installer|package installer]] know that there are files to extract, and that they are part of the template as a whole.
+
<translate>
 +
<!--T:14-->
 +
The above code in essence lets the Joomla! [[S:MyLanguage/Installer|package installer]] know that there are files to extract, and that they are part of the template as a whole.
 +
</translate>
 +
 
 +
<translate>== Further tips == <!--T:15--></translate>
 +
<translate>
 +
<!--T:22-->
 +
You can '''override''' Joomla's '''core images''' that are stored in the /media/ folder. Put an alternative image with the same name in your template folder. For example, the Breadcrumbs Module uses an orange arrow that is retrieved from '''/media/system/images/arrow.png'''. Joomla will use your override version if you put it at  '''/templates/your_template_name/images/system/arrow.png'''.
 +
</translate>
 +
 
 +
<translate>
 +
<!--T:16-->
 +
Template overrides are almost limitless. They allow you to add, edit, and remove the components of the Joomla! core output.  [[S:MyLanguage/J3.2:How_to_use_the_Template_Manager#Creating_Overrides|The Template Manager can be used to create override files]] ready for editing.
 +
</translate>
 +
 
 +
<translate>
 +
<!--T:17-->
 +
Note: For the FireFox web browser, an extension called [https://addons.mozilla.org/en-US/firefox/addon/1843 Firebug] is available, which is useful for browsing a page's HTML source and matching it up with the PHP code used in template overrides. For more information, please watch [[S:MyLanguage/Using Firebug With Your Joomla Website|the free video tutorial on using Firebug with Joomla]].
 +
Now firebug is also available for IE called [http://getfirebug.com/lite/ie.html Firebug Lite].
 +
</translate>
  
===Further tips===
+
<translate><!--T:18-->
Template overrides are almost limitless. They allow you to add, edit, and remove the components of the Joomla! core output.  
+
More information is available from the following resources:</translate>
Note: For the FireFox web browser, an extension is available called [https://addons.mozilla.org/en-US/firefox/addon/1843 Firebug], which is useful for browsing a page's HTML source and matching it up with the PHP code used in template overrides. A free video tutorial on using Firebug with Joomla is available [[Tutorial:Using_Firebug_With_Your_Joomla_Website|here]].
+
<translate>
Now firebug is also available for IE called [http://getfirebug.com/lite/ie.html Firebug Lite]
+
<!--T:19-->
 +
* The article [[S:MyLanguage/Understanding Output Overrides|Understanding Output Overrides]] explains the theory behind template overrides.
 +
* The preferred way of changing text output is by [[S:MyLanguage/Making templates translatable|using translations in your template]].
 +
</translate>
 +
<translate>
 +
<!--T:20-->
 +
* A [http://help.joomla.org/ghop/feb2008/task059/Getting_Started_with_Template_Overrides_v2.tar.gz downloadable tutorial] is also available.
 +
* [https://github.com/AmyStephen/Layout-Override-Plugin Example in github] how to override layout of view without override the view, but extending it.
 +
</translate>
  
More information is available from the following resources:
 
* The article [[Understanding Output Overrides]] explains the theory behind template overrides.
 
* [[Tutorial:Template_translations]] can also be used to alter the output of components
 
 
<noinclude>
 
<noinclude>
 +
<translate>
 +
<!--T:21-->
 +
[[Category:Tutorials]]
 
[[Category:Templates]]
 
[[Category:Templates]]
[[Category:Tips and tricks]] [[Category:Tips and tricks 1.5]]
+
[[Category:Tips and tricks]]
 +
[[Category:Tips and tricks 1.5]]
 +
[[Category:Tips and tricks 1.6]]
 
[[Category:Overrides]]
 
[[Category:Overrides]]
 +
</translate>
 
</noinclude>
 
</noinclude>

Revision as of 13:15, 19 August 2015

This page has been archived. This page contains information for an unsupported Joomla! version or is no longer relevant. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Other languages:
Deutsch • ‎English • ‎Nederlands • ‎español • ‎français • ‎Ελληνικά • ‎български

There may be occasions where you would like to change the way a Joomla! Extension (such as a Component or Module, whether from the Joomla! core or produced by a third party) is displayed on your site. Of course, you could recode the Extension from scratch, but that may be a bit ambitious for you! Thankfully, there is another way.

The standard output from any Joomla! Module or Component can be overridden by adding code to the html directory of your template. It is also possible to override two aspects of core functionality: Module chrome, and pagination.

As of Joomla 3.2 overrides can be created using the Template manager Creating Overrides

Getting a head-start with overrides[edit]

If you are new to Joomla! development, then it is probably easiest to start with an existing view, and try modifying it to get what you want. To do this, you should make a copy of the existing view in the html directory of your template, and then modify the copy.

The directory structure you need is:

TEMPLATE_NAME/html/EXTENSION_NAME/VIEW_NAME/FILE_NAME.php

For example, if you want to change the way that the 'Article' view displays a com_content article, then you should copy the file at :

PATH_TO_JOOMLA/components/com_content/views/article/tmpl/default.php
to
TEMPLATE_NAME/html/com_content/article/default.php

(note the slight difference in directory structure)

Similarly, if you want to change how the mod_login Module is displayed, then you should copy :

PATH_TO_JOOMLA/modules/mod_login/tmpl/default.php
to
TEMPLATE_NAME/html/mod_login/default.php

Joomla! comes pre-packaged with a frontend template called Beez. Beez utilizes template overrides to produce a table-less layout for faster, smoother, and semantically correct markup. To see how it's done, locate your Joomla! installation's template directory, and you'll notice the Beez template. Inside the Beez template directory, you'll find a directory named html.

The entire directory structure is as follows:

/your_joomla/templates/Beez/html/

If you want to try modifying the overrides used in Beez, you could simply copy and paste the Beez html directory into your own template's main directory. However you choose to make your override files, you will need to ensure that they are correctly installed with your template. To do this, you should add the following code to your template's templateDetails.xml file (in between the <files> and </files> tags):

<folder>html</folder>

The above code in essence lets the Joomla! package installer know that there are files to extract, and that they are part of the template as a whole.

Further tips[edit]

You can override Joomla's core images that are stored in the /media/ folder. Put an alternative image with the same name in your template folder. For example, the Breadcrumbs Module uses an orange arrow that is retrieved from /media/system/images/arrow.png. Joomla will use your override version if you put it at /templates/your_template_name/images/system/arrow.png.

Template overrides are almost limitless. They allow you to add, edit, and remove the components of the Joomla! core output. The Template Manager can be used to create override files ready for editing.

Note: For the FireFox web browser, an extension called Firebug is available, which is useful for browsing a page's HTML source and matching it up with the PHP code used in template overrides. For more information, please watch the free video tutorial on using Firebug with Joomla. Now firebug is also available for IE called Firebug Lite.

More information is available from the following resources: