home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / block.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  1.1 KB  |  54 lines

  1. <?php
  2.  
  3. include_once 'HTML/Template/PHPLIB.php';
  4. include_once 'Benchmark/Timer.php';
  5.  
  6. $articles = array(
  7.     "ISBN345624345" => "Matrix 2",
  8.     "ISBN45df32342" => "Roger Rabbit",
  9.     "ISBN305632232" => "foo bar",
  10.     "ISBN674589123" => "Joe user's adventures"
  11. );
  12.  
  13. class myT extends Template_PHPLIB {
  14.     var $file_fallbacks = array("/usr/local/bla","./");
  15. }
  16.  
  17. $t =& new myT("/usr/local", "keep");
  18.  
  19. $timer =& new Benchmark_Timer();
  20. $timer->start();
  21.  
  22. $t->setFile(array(
  23.     "main" => "tpl1.ihtml",
  24.     "block" => "block.ihtml"
  25. ));
  26.  
  27. $t->setBlock("block","articlerow","ar");
  28.  
  29. $t->setVar(array(
  30.     "TITLE" => "This is a block integrated into another template",
  31.     "BGCOLOR" => "#cccccc",
  32.     "BLOCKER" => "block"
  33. ));
  34.  
  35. foreach ($articles as $isbn => $name) {
  36.     $t->setVar(array(
  37.         "ID" => $isbn,
  38.         "ANAME" => $name
  39.     ));
  40.     /**
  41.     * easy to use rule of thumb: first parameter is the last
  42.     * from setBlock, second is the second from setBlock, third
  43.     * is TRUE in order to append the parsed data to the template var
  44.     * articlerow
  45.     */
  46.     $t->parse("ar", "articlerow", TRUE);
  47. }
  48.  
  49. $t->parse("CONTENT", "block");
  50. $t->pparse("out",array("main"));
  51. $timer->stop();
  52. $timer->display();
  53. ?>
  54.