SKOR PHP Template


/ Published in: PHP
Save to your folder(s)

Skor PHP Template class can assign individual variable values or arrays with several variable values. A separate sub-class extends the base class to support delimited template section replacements.


Copy this code and paste it in your HTML
  1. <?php
  2. require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'class_template.php');
  3. require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'class_section.php');
  4.  
  5. /**
  6. * class section "Intro" *
  7. **/
  8. $sec = new section();
  9. $sec->dir = dirname(__FILE__).DIRECTORY_SEPARATOR;
  10. $sec->html = 'section.html';
  11. $sec->read();
  12.  
  13. /**
  14. * class section "Hello world" *
  15. **/
  16. $sec->assign_section('Head');
  17. $sec->assign('HALLO','Hi World');
  18. $sec->assign_section('Example');
  19.  
  20. /**
  21. * class section "Alternating table rows" *
  22. **/
  23. $tbody = '';
  24. for($i = 0; $i <= 5; $i++){
  25.  
  26. $sec->assign('COUNTER', $i);
  27.  
  28. if(is_int($i/2)){
  29. $tbody .= $sec->fetch('RowGreen');
  30. }else{
  31. $tbody .= $sec->fetch('RowRed');
  32. }
  33. }
  34. $sec->assign('TBODY',$tbody);
  35. $sec->assign_section('Table');
  36.  
  37. /**
  38. * class section "Nested sections with two children" *
  39. **/
  40. $sec->assign('PLACEHOLDER','placeholder');
  41. $sec->assign('MOTHER',$sec->fetch('ChildOne') . $sec->fetch('ChildTwo'));
  42. $sec->assign_section('Mother');
  43.  
  44. /**
  45. * class section footer" *
  46. **/
  47. $sec->assign_section('End');
  48. ?>

URL: http://template.ecoware.de

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.