<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title> Template integration </title> <link rel="stylesheet" href="book.css" type="text/css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.69.1" /> <link rel="start" href="index.html" title="HTML_Progress2 Manual" /> <link rel="up" href="ch09.html" title= "Chapter 9. Quick Start with HTML_Progress2_Generator" /> <link rel="prev" href="ch09s02.html" title="Default render and css skin" /> <link rel="next" href="ch10.html" title= "Chapter 10. How to to implement an AJAX Progress Bar" /> <style type="text/css"> /*<![CDATA[*/ body { background-color: white; color: black; } :link { color: #0000FF } :visited { color: #840084 } :active { color: #0000FF } div.c3 {margin-left: 0.5in; margin-right: 0.5in;} div.c2 {font-family: monospace;} h2.c1 {clear: both} /*]]>*/ </style> </head> <body> <table class="progress2Header"> <tr> <td> <img src="img/pear_progress2.gif" align="left" alt= "PEAR Progress2 logo" /> <h1> HTML_Progress2 : The Definitive Guide </h1> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center"> Template integration </th> </tr> <tr> <td width="20%" align="left"> <a accesskey="p" href="ch09s02.html">Prev</a> </td> <th width="60%" align="center"> Chapter 9. Quick Start with HTML_Progress2_Generator </th> <td width="20%" align="right"> <a accesskey="n" href="ch10.html">Next</a> </td> </tr> </table> </div> </td> </tr> </table> <div class="sect1" lang="en" xml:lang="en"> <div class="titlepage"> <h2 class="title c1"> <a name="generator.template.engine" id= "generator.template.engine"></a>Template integration </h2> </div> <p> 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. </p> <p> Don't forget that you can also use the PEAR <a class="external" href= "http://pear.php.net/package/HTML_Page2" title= "http://pear.php.net/package/HTML_Page2">HTML_Page2</a> package and since the version 2.1.0 the new Tableless QF renderer (PEAR package <a class="external" href= "http://pear.php.net/package/HTML_QuickForm_Renderer_Tableless" title= "http://pear.php.net/package/HTML_QuickForm_Renderer_Tableless">HTML_QuickForm_Renderer_Tableless</a>). </p> <p> 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 <a class="external" href= "http://pear.php.net/package/HTML_Template_Sigma" title= "http://pear.php.net/package/HTML_Template_Sigma">Sigma</a>, but there is no much more difficulty to implement Smarty, or any other template engine. </p> <p> Color, font, size and position are defined by default in stylesheet <span class="bold"><strong>itdynamic.css</strong></span> you can find into PEAR HTML_Progress2 data directory. </p> <div class="screenshot"> <img src="img/generator1.png" alt="" /> </div> <p> Essantial difference with previous examples is to include the right driver (ITDynamic). </p> <div class="php c2"> <ol> <li class="li1"> <div class="de1"> <span class="kw2"><?php</span> </div> </li> <li class="li1"> <div class="de1"> <span class="kw1">require_once</span> <span class= "st0">'HTML/Progress2/Generator.php'</span><span class= "sy0">;</span> </div> </li> <li class="li1 ln-xtra"> <div class="de1"> <span class="kw1">require_once</span> <span class= "st0">'HTML/Progress2/Generator/ITDynamic.php'</span><span class= "sy0">;</span> </div> </li> <li class="li1"> <div class="de1"> </div> </li> <li class="li1"> <div class="de1"> <span class="kw3">session_start</span><span class= "br0">(</span><span class="br0">)</span><span class= "sy0">;</span> </div> </li> <li class="li1"> <div class="de1"> </div> </li> <li class="li1"> <div class="de1"> <span class="re1">$tabbed</span> <span class="sy0">=&</span> HTML_Progress2_Generator<span class="sy0">::</span><span class= "me2">singleton</span><span class="br0">(</span><span class= "br0">)</span><span class="sy0">;</span> </div> </li> <li class="li1"> <div class="de1"> <span class="re1">$tabbed</span><span class= "sy0">-></span><span class="me1">run</span><span class= "br0">(</span><span class="br0">)</span><span class= "sy0">;</span> </div> </li> <li class="li1"> <div class="de1"> <span class="kw2">?></span> </div> </li> </ol> </div> <div class="variablelist"> <dl> <dt> <span class="term">Line 3 :</span> </dt> <dd> <p> 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'. </p> <div class="caution c3"> <table border="0" summary="Caution"> <tr> <td rowspan="2" align="center" valign="top" width="48"> <img alt="[Caution]" src="img/admons/caution.png" /> </td> <th align="left"> Caution </th> </tr> <tr> <td align="left" valign="top"> 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 : <div class="php c2"> <ol> <li class="li1"> <div class="de1"> <span class="kw2"><?php</span> </div> </li> <li class="li1"> <div class="de1"> <span class="re1">$tpl</span> <span class= "sy0">=&</span> <span class="kw2">new</span> HTML_Template_Sigma<span class= "br0">(</span><span class= "st0">'.'</span><span class="sy0">,</span> <span class="st0">'cache/'</span><span class= "br0">)</span><span class="sy0">;</span> </div> </li> <li class="li1"> <div class="de1"> <span class="re1">$tpl</span><span class= "sy0">-></span><span class= "me1">loadTemplateFile</span><span class= "br0">(</span><span class= "st0">'itdynamic.html'</span><span class= "br0">)</span><span class="sy0">;</span> </div> </li> <li class="li1"> <div class="de1"> <span class="kw2">?></span> </div> </li> </ol> </div>No more, no less ! </td> </tr> </table> </div> </dd> </dl> </div> </div> <table class="progress2Footer"> <tr> <td align="left"> HTML_Progress2 : The Definitive Guide </td> <td align="right"> v 2.4.0 : April 20, 2007 </td> </tr> </table> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"> <a accesskey="p" href="ch09s02.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="ch09.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="ch10.html">Next</a> </td> </tr> <tr> <td width="40%" align="left" valign="top"> Default render and css skin </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> Chapter 10. How to to implement an AJAX Progress Bar </td> </tr> </table> </div> </body> </html>