Menu Content

Currencies Accepted


Shopping Cart

cart
Your Cart is currently empty.

How to Download A Product

For most of our products, including the free ones, you will need to go through checkout and place an order.

Read More

 

Find Us Elsewhere

Follow us on Twitter

Spiral Scripts on Facebook

rapidssl_ssl_certificate
2Checkout.com is a worldwide leader in payment services

Google ads

Home » Joomla Tips » Using Template Overriding With Joomla

Using Template Overriding With Joomla PDF Print E-mail

It often happens when you are using a Joomla component or module that you would like to modify the display of the extension in some way.

If the extension uses the MVC (model-view-controller) layout then there is a straightforward way to do this - use template overriding.

How Do I Know If An Extension Supports Template Overriding?

You can tell if an extension supports template overriding by examining the file structure.

If the extension is a component then its site folder should contain a'views' folder, with the templates being stored in sub-folders corresponding to the views that the component supports. The Joomla content component gives a good example of this.

A module does not support different views, so its layout is somewhat simpler. The templates should be stored in a module folder called tmpl.

 

Example - Overriding the Joomla Article Display

For example, the Joomla content component keeps its templates in the folder components/com_content/views/. This contains a set of sub-folders named for the various types of view that Joomla supports: archive, article, category, front-page and section. The templates for the component are stored in a sub-folder called 'tmpl' inside each of these view folders.

To override one of these templates simply place your edited version of in a folder called html in your site template folder. For example, the default layout for a Joomla article is defined in the file

components/com_content/views/article/tmpl/default.php

To override this place your own version in the file

templates/mytemplate/html/com_content/article/default.php

where 'mytemplate' is replaced by the actual name of your template of course. Your version of default.php will have access to the same template variables as the original default.php: you can arrange them in any way that you wish.

Using Template Overriding With Our Extensions

Our own extensions also use the MVC layout, so that you can use template overriding with them. For example our module Featured Items Pro stores its templates in the module folder called tmpl. To override the default template for the module, create a file in your template folder:-

templates/mytemplate/html/mod_featureditems_pro/default.php

Your edited version of the template will have access to all the module template variables. These are stored in an array called $list. The template loops through these displaying each list item in turn. Each list item is an object with the following properties defined:-

  • $item->link - the link to the article
  • $item->author - the article author
  • $item->created - the article creation date
  • $item->modified - the article modification date
  • $item->imageTag - the article image tag
  • $item->text - the article extract
  • $item->readmore - the article readmore (readmore text with link)

Additionally the module parameters can be access through the $params JParameter object. For example, to get the module class suffix use

$params->get('moduleclass_sfx')

So you can see that template overriding allows you the ultimate control over extension layout.


Spiral Scripts
Written on Thursday, 22 July 2010 13:42 by Spiral Scripts

Viewed 6948 times so far.
Like this? Tweet it to your followers!

Latest articles from Spiral Scripts

  • New Image Slideshow for Joomla 1.6/1.7/2.5 posted on Monday, 23 January 2012 17:27

    We are happy to announce the release of our new image slideshow module for Joomla…

  • Mod Panel Slider Documentation posted on Saturday, 21 January 2012 10:42

    Our Panel Slider Module displays your images in an attractive and unusual scrolling slideshow. Display…

  • New Tool for Joomla Developers posted on Saturday, 14 January 2012 11:51

    Self-Replicating Form Field for Joomla There are times as a Joomla extension developer when it…

  • Variable Form Field Documentation posted on Thursday, 12 January 2012 13:24

    The variable field form field can be used to generate self-replicating fields of most of…

  • Virtuemart 2.0 Released posted on Thursday, 05 January 2012 11:16

    On 19th December the much anticipated Virtuemart 2.0.0 was released. This is a great achievement…

Latest 'tweets' from Spiral Scripts

  • Some useful Joomla mailing lists http://t.co/lBNEoAcK Link Wednesday, 01 February 2012 12:31
  • New Image Slideshow for Joomla 1.6/1.7/2.5 http://t.co/z9Utb8z9 Link Monday, 23 January 2012 18:14
  • New Image Slideshow for Joomla 1.6/1.7/2.5: We are happy to announce the release of our new image slideshow modu... http://t.co/bWb5VBPh Link Monday, 23 January 2012 17:57
  • New Tool for Joomla Developers http://t.co/jm4F3OlS Link Saturday, 14 January 2012 13:51
  • New Tool for Joomla Developers: Self-Replicating Form Field for Joomla There are times as a Joomla extension dev... http://t.co/myKPsmLh Link Saturday, 14 January 2012 12:17
blog comments powered by Disqus

 
 
 

VirtueMart Featured Products Grid

Switch View

This module can be used as a replacement for the Virtuemart featured products, top products, random products or recent products modules. It displays product images as a 3 Dimensional Flash slideshow.

£15.00


This module displays a short excerpt from articles in a selected category or section, or from a specified list of articles, with link and optional thumbnail image.

£12.00


Buy both our Flash slideshow products for Virtuemart and save £5.

£25.00


A featured items module that shows selected entries from the SOBI2 business index.

£12.00