DEPRECATION WARNING
This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.
EXT: Photogallery express¶
Author: | Kasper Skårhøj |
---|---|
Created: | 2002-11-01T00:32:00 |
Changed: | 2006-08-31T10:22:43 |
Author: | Patrick Kapar |
Email: | info@patie.nl |
Info 3: | |
Info 4: |
EXT : XTemplate for Typo3¶
Extension Key: xtemplate
Copyright 2006, Fabien Udriot, <fabien.udriot@ecodev.ch>
This document is published under the Open Content License
available from http://www.opencontent.org/opl.shtml
The content of this document is related to TYPO3
- a GNU/GPL CMS/Framework available from www.typo3.com
Table of Contents¶
EXT : Xtemplate for Typo3 1
Introduction 1
What does it do? 1
Examples 2
A simple example 1 2
A simple example 2 2
Further documentation 3
Knows Problems 3
Todo List 3
Changed Log 3
Introduction¶
What does it do?¶
XTemplate is a simple and very powerful template engine. It is used in many large scaled projects and in many open source CMSs. It has proven its scalability and its stability.
XTemplate is similar to Smarty (Maybe you have heard about it...). The template syntax is very close and the separation between PHP and HTML is well implemented rendering it very userfriendly. Though Smartly is certainly one of the richest template engines, it is also quite fat... Smarty has over 3000 lines of code to include each time ! For my typo3 extension needs, it is simply an overkill !
Furthermore, I was not satisfied with the Typo3 template engine. The tslib_cObj class wich provides all the necessary functions is quite complicated to use, particularly with complex templates (loop of a loop...). I find also the separation between HTML and PHP not as evident as other template engine...
In regard of this, I decided to use XTemplate for my frontend plugins development as main template engine. As mentioned above, XTemplate is designed to be very fast in template processing... Although it's introduce a dependency to my extension, my code looks much cleaner and shorter. The maintainability level is simply better...
To make it work, I have slightly changed a few lines in the XTemplate class in order to integrate it in Typo3.
How does it function ? You will find in the next paragraph a simple example...
Examples¶
A simple example 1 :¶
PHP code :¶
// instantiate the object
$xtpl = new tx_xtemplate('file.xtpl');
// simple replace
$xtpl->assign('HELLO_WORLD', 'Hello World !');
// simple replace
$xtpl->parse('block1');
// display the content
$output = $xtpl->out('block1');
echo $output;
A simple example 2 :¶
HTML code :¶
<!-- BEGIN: block2 -->
<table border="1">
<tr>
<td>Say hello : </td>
<td>{DATA}</td>
</tr>
</table>
<!-- END: block -->
PHP code :¶
// instantiate the object
$xtpl = new tx_xtemplate('file.xtpl');
// loop replacement
$sayHello = array('hello','bonjour','guten Tag','buenas dias');
foreach($sayHello as $hello){
$xtpl->assign('DATA', $hello);
$xtpl->parse('block2');
}
// display the content
$output = $xtpl->out('block1');
echo $output;
Further documentation¶
It's not the purpose to explain here how XTemplate works in detail. XTemplate has a very good documentation. If you are interested to play with XTemplate and use it in you extensions, I recommend you read:
- the 7 basic examples here : http://www.phpxtemplate.org/DocumentationBasics
- have a look of this extension : eco_gal
Known problems¶
Post in the feed-back section on typo3.org/extensions/ ...
To-Do list¶
Post in the feed-back section on typo3.org/extensions/ ...
Changelog¶
- 1.7: first release, corresponds to the XTemplate version.
EXT: Photogallery express - 3