PEAR Progress2 logo

HTML_Progress2 : The Definitive Guide

Template integration

If you already use HTML_QuickForm you certainly know that the QF default renderer has limited possibilities. But of course HTML_QuickForm provides other renderers that can be used with template engines such as Smarty, Sigma, ... And of course HTML_Progress2_Generator has two interfaces (SmartyDynamic, ITDynamic) to use these QF renderers.

Don't forget that you can also use the PEAR HTML_Page2 package and since the version 2.1.0 the new Tableless QF renderer (PEAR package HTML_QuickForm_Renderer_Tableless).

In this example, we will see how it's so easy to include an instance of HTML_Progress2_Generator in a user page (with header and menus, body, footer); see screenshot below. We will use Sigma, but there is no much more difficulty to implement Smarty, or any other template engine.

Color, font, size and position are defined by default in stylesheet itdynamic.css you can find into PEAR HTML_Progress2 data directory.

Essantial difference with previous examples is to include the right driver (ITDynamic).

  1. <?php
  2. require_once 'HTML/Progress2/Generator.php';
  3. require_once 'HTML/Progress2/Generator/ITDynamic.php';
  4.  
  5. session_start();
  6.  
  7. $tabbed =& HTML_Progress2_Generator::singleton();
  8. $tabbed->run();
  9. ?>
Line 3 :

Adding this line allow to define an ActionDisplay class (default name to display driver) that will create a new instance of Sigma with current directory '.' as template root dir, and 'cache/' as template cache dir. The template itself is named 'itdynamic.html'.

[Caution] Caution
You can, of course reuse such values with your own documents, or use new ones. In such condition, you will have to create a copy of ActionDisplay class (HTML/Progress2/Generator/ITDynamic.php) and replace lines :
  1. <?php
  2. $tpl =& new HTML_Template_Sigma('.', 'cache/');
  3. $tpl->loadTemplateFile('itdynamic.html');
  4. ?>
No more, no less !
HTML_Progress2 : The Definitive Guide v 2.4.0 : April 20, 2007