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. * $Id: fsource_XTemplate__ex1.php.html,v 1.3 2005/04/11 10:00:49 cocomp Exp $
  10. */
  11.  
  12. include_once('./xtemplate.class.php');
  13.  
  14. $xtpl = new XTemplate('ex1.xtpl');
  15. // simple replace
  16. $xtpl->assign('VARIABLE', 'TEST');
  17. // parse block1
  18. $xtpl->parse('main.block1');
  19. // uncomment line below to parse block2
  20. //$xtpl->parse('main.block2');
  21.  
  22.  
  23. /**
  24. * you can reference to array keys in the template file the following way:
  25. * {DATA.ID} or {DATA.NAME}
  26. * say we have an array from a mysql query with the following fields: ID, NAME, AGE
  27. */
  28. $row = array('ID'=>'38',
  29. 'NAME'=>'cocomp',
  30. 'AGE'=>'33'
  31. );
  32. $xtpl->assign('DATA',$row);
  33.  
  34. // parse block3
  35. $xtpl->parse('main.block3');
  36.  
  37. $xtpl->parse('main');
  38. $xtpl->out('main');
  39.  
  40. /*
  41. $Log: fsource_XTemplate__ex1.php.html,v $
  42. Revision 1.3 2005/04/11 10:00:49 cocomp
  43. Added restart() method sf:641407 feature request
  44. Revision 1.2 2005/04/07 12:02:51 cocomp
  45. MAJOR UPDATE: E_ALL safe, better internal documentation, code readability ++, many bugfixes and new features - considered stable
  46. Revision 1.1 2001/07/11 10:49:25 cranx
  47. *** empty log message ***
  48. Revision 1.2 2001/03/26 23:25:02 cranx
  49. added keyword expansion to be more clear
  50. */
  51.  
  52. ?>

Documentation generated on Mon, 11 Apr 2005 10:59:08 +0100 by phpDocumentor 1.3.0RC3