Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php]System szablonów, proszę o sprawdzenie
Joachim Peters
post
Post #1





Grupa: Zarejestrowani
Postów: 196
Pomógł: 2
Dołączył: 1.03.2006

Ostrzeżenie: (0%)
-----


Potrzebuje prostego systemu szablonów, który będzie wstanie obsłużyć foreach.
Zdołałem zrobić coś takiego
  1. <?php
  2. class Template {
  3. static $templates;
  4. static $dir;
  5. static $vars = array();
  6.  
  7. public function __construct($templates = 'default', $dir = './styles/') {
  8. self::$templates = $templates;
  9. self::$dir = $dir;
  10. }
  11.  
  12. public static function assign($key, $value) { 
  13. self::$vars[$key] = $value;
  14. }
  15.  
  16. public static function display($file) {
  17. if( $file ) {
  18. $file = self::$dir . self::$templates . '/' . $file;
  19. if( @file_exists( $file ) && @is_readable( $file ) ) {
  20. extract( self::$vars, EXTR_SKIP );
  21. include_once( $file );
  22. }
  23. }
  24. }
  25. }
  26. ?>


Da się coś z tego zrobić czy skorzystać z innych skryptów?
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 20:03