HTML_Template_PHPLIB
[ class tree: HTML_Template_PHPLIB ] [ index: HTML_Template_PHPLIB ] [ all elements ]

Source for file block.php

Documentation is available at block.php

  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 HTML_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. ?>

Documentation generated on Tue, 10 Dec 2019 05:16:06 -0500 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.