Project

General

Profile

Actions

Templates

This is a brainstorm page for the template engine in chamilo 2.0.
First we need to do some research regarding templating and the several template engines for php.

Useful information

Several Template Engines

Things the template engine should be able to do

  • Support variables like {TITLE} {DESCRIPTION}
  • Support loops
  • Support conditions

Things we should take into account when integrating the template engine

  • Javascript support at the level of templates
  • Ajax support ? (only javascript side)

What to do to implement the template engine

  • Decide which template engine to use
  • Put the template engine in the plugin's folder
  • Optional: Create a chamilo wrapper around it
  • Start moving header, footer, banner to it.
  • Start extending it for components
  • Optional: Move or try to integrate quickform into the templates

The decision process

  • Smarty
    • Advantages
      • Many functions
      • Caching
      • Good for very advanced users
    • Disadvantages
      • Package is to heavy for our needs (to many functions we won't need)
      • Package will cause unnecessary performance problems
  • phpBB 2.0 Template Engine
    • Advantages
      • Very easy to use
      • Supports the needs we currently have
      • Very small and lightweight (no performance issues) (only 1 class)
      • Very easy to extend, adapt
      • Almost not integrated with phpbb kernel and therefore useable out of the box
    • Disadvantages
      • No Caching
  • phpBB 3.0 Template Engine
    • Advantages
      • Easy to use
      • Supports the needs we currently have
      • Caching available
      • Lightweight and small (only 2 classes - 1 for template, 1 for caching)
      • Normal level needed to extend or adapt
    • Disadvantages
      • Integrated with phpbb kernel (user class, ...) - We will need some time to split the kernel code from it and create our own wrapper for it.
  • PHP Based Template Engine
    • Advantages
      • Many possibilities
      • More easy integration of quickform, pear html pacakges, etc
      • Caching can be possible with php caching systems
      • No extra layer needed, no problems with performance
    • Disadvantages
      • Designers need to know basic php
      • Many security issues
      • Dangerous to have business logic and presentation logic mixed

Choose between phpbb2 and phpbb3 engine

Featurelist

  • phpBB2
    • Caching
    • Variables
    • Blocks which are used for:
      • Loops
      • Conditions
    • Include of templates
  • phpBB3
    • Caching
    • Variables
    • Blocks which are used for:
      • Loops
    • Conditions
    • Include of templates
    • DEFINE / UNDEFINE
    • Include of PHP
    • Execution of PHP

The big differences between the base of phpbb2 and phpbb3 is that in phpbb3 we have a decent split between loops and conditions (where as in 2.0 the loops and conditions go through blocks) and the support for php from within a template.

First implementation

A first implementation tryout of the phpbb2 engine can be found at
http://code.google.com/p/chamilo/source/detail?r=b9391c8425ad96d37de16afc1c4ff9b5d06b91ec&repo=chamilo

We have the basic almost unchanged class (a few minor changes excluded) called phpbb2 template in the plugins folder. We have created a wrapper file called phpbb2 template wrapper to include both caching and the possibility to return instead of using echo. The theme class creates an instance of the template engine. An example has been worked out for the footer class. The templates can be found in root/layout/theme/templates and the cache can be found in root/files/cache/layout/theme/.

Updated by Sven Vanpoucke over 12 years ago ยท 14 revisions