XiTemplate Home Page XiTemplate
[ class tree: XiTemplate ] [ index: XiTemplate ] [ all elements ]

Example usage of parse()

  1. <?php
  2. /*include the class*/
  3. include_once('../class.XiTemplate.php');
  4.  
  5. /*instantiate the class and pass the path to your html template file*/
  6. $xitpl = new XiTemplate('templates/parse.tpl');
  7.  
  8. /*assign a value to a template variable.*\
  9. /*In this example {NAME} will be replaced with "XiTemplate"*/
  10. $xitpl->assign('NAME', 'XiTemplate');
  11.  
  12. /*let's make dynamically make a table*/
  13. $rows = 3;
  14. $cols = 4;
  15.  
  16. for ($i = 0; $i < $rows; $i++) /*loop to make the tr's*/
  17. {
  18. for ($x = 0; $x < $cols; $x++) /*loop to make the td's*/
  19. {
  20. $xitpl->assign('VARIABLE', 'row: '.($i+1).', column: '.($x+1));
  21. /*notice the hierarchy by which blocks must be parsed...*/
  22. $xitpl->parse('main.tr.td');
  23. }
  24. /*...always parse child blocks first*/
  25. $xitpl->parse('main.tr');
  26. }
  27.  
  28. /*parse the "main" block of the template (the whole page)*/
  29. $xitpl->parse('main');
  30.  
  31. /*send the final page out to the browser*/
  32. $xitpl->out('main');
  33. ?>

Documentation generated on Fri, 20 Aug 2004 10:57:45 -0500 by phpDocumentor 1.3.0RC3