Source for file ex1.php

Documentation is available at ex1.php

  1. <?php
  2.  
  3. /**
  4. * example 1
  5. * demonstrates basic template functions
  6. * -simple replaces ( {VARIABLE1}, and {DATA.ID} {DATA.NAME} {DATA.AGE} )
  7. * -dynamic blocks
  8. *
  9. * @package XTemplate_Examples
  10. * @author Barnabas Debreceni [cranx@users.sourceforge.net]
  11. * @copyright Barnabas Debreceni 2000-2001
  12. * @author Jeremy Coates [cocomp@users.sourceforge.net]
  13. * @copyright Jeremy Coates 2002-2007
  14. * @see license.txt LGPL / BSD license
  15. * @link $HeadURL: https://xtpl.svn.sourceforge.net/svnroot/xtpl/trunk/ex1.php $
  16. * @version $Id: ex1.php 16 2007-01-11 03:02:49Z cocomp $
  17. */
  18.  
  19. include_once('./xtemplate.class.php');
  20.  
  21. $xtpl = new XTemplate('ex1.xtpl');
  22.  
  23. // simple replace
  24. $xtpl->assign('VARIABLE', 'TEST');
  25.  
  26. // parse block1
  27. $xtpl->parse('main.block1');
  28.  
  29. // uncomment line below to parse block2
  30. //$xtpl->parse('main.block2');
  31.  
  32.  
  33. /**
  34. * you can reference to array keys in the template file the following way:
  35. * {DATA.ID} or {DATA.NAME}
  36. * say we have an array from a mysql query with the following fields: ID, NAME, AGE
  37. */
  38. $row = array('ID'=>'38',
  39. 'NAME'=>'cocomp',
  40. 'AGE'=>'33'
  41. );
  42.  
  43. $xtpl->assign('DATA',$row);
  44.  
  45. // parse block3
  46. $xtpl->parse('main.block3');
  47.  
  48. $xtpl->parse('main');
  49. $xtpl->out('main');
  50.  
  51. ?>

Documentation generated on Tue, 29 May 2007 19:29:33 +0100 by phpDocumentor 1.3.0RC3