Templates overriding : a small Tutorial

alain01  09-Sep-2006 13:47 12511 Reads   11 Comment(s) 
This article, translated from french to english by Tripmon(many many thanks to him)/Marco, will explain the Template override concept, a feature introduced from XOOPS 2.0.14.
This news is here in order to help users understand this new concept. This article will demonstrate that by 2 examples.

First, What is a template ?
Templates can display data (as well as sort, position, and conditional display...)
Templates are used to separate the process of displaying data from retrival and manipulation.
This allows non programmers to easily format data for presentation, without modifying underlying code, by simply modifying the template file.

XOOPS comes with its own templates (module system, 26 files), for example:
- system_redirect.html (Redirection page)
- system_siteclosed.html (Closed site page)
- system_block_login.html (Login block)
- system_block_online.html (User on line block)
- system_block_comments.html (Comments block)...

Every recent module also uses templates (pages and blocks).

Example :
News module (15 templates) for example:
- news_archive.html (archives page)
- news_block_new.html (New news block)
- news_block_top.html (better read news block)...

To browse these templates, go to admin system / templates and click on list on the module that you want to see, on the default template set.
The top section shows template pages, with template blocks below.

If these pages and blocks do not display to your liking, it's not a problem, you can modify them with the new functionality included in the core since XOOPS 2.0.14:
Templates overriding.

An excerpt from XOOPS 2.0.14 news:
Designers can add custom templates to their themes, and those will be used instead of the default ones.
To exploit this feature, templates have to be created in subfolders of the themes duplicating the default folders structure and removing the "templates" part:
To overload :
system_userinfo.html (template located in modules/system/templates/system_userinfo.html), you have to create your custom version in:

To overload :
system_block_login.html (template located in modules/system/templates/blocks/system_block_login.html), you have to create your custom version in:


Now, You don't need to clone your default template set, you can use the default template set (in fact, to override, you MUST), and install the structure file of your modules in the <yourthemefolder> directory.

Bonus :
- In case of "Update" module, your modified files will not be suppressed
- Just modified templates will be installed in <yourthemefolder> directory
- The understanding of custom templates is very easy now (structured files)
- Easy to use
- You can change themes very easily by overriding the default template pack (for example, login block, search block, close site block...)

Page 2: Example 1
Page 3: Example 2
Page 4: Notes and image & css overriding...
(1) 2 3 4 »
Rating 0/5
Rating: 0/5 (0 votes)
Voting is disabled!


Who's Online

98 user(s) are online (4 user(s) are browsing Publisher)

Members: 0

Guests: 98



Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits