Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php + html] Problem z templatkami
Yazzie
post
Post #1





Grupa: Zarejestrowani
Postów: 37
Pomógł: 0
Dołączył: 5.04.2007
Skąd: Otwock

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


Mam takie oto kody.

index.php

  1. <?php
  2. include ("db_config.php");
  3. include ("includes/functions.php");
  4.  
  5. $template = new template (); 
  6.  
  7. $template-> add_file("header.tpl");
  8. $template-> add_file("index.tpl");
  9. $template-> add_file("footer.tpl");
  10.  
  11. @include ("language/polish/main.php");
  12.  
  13. $template-> set_template(array(
  14. "LANG_POWERED_INFO" => $lang['powered_info'],
  15. "LANG_WELCOME" => $lang['welcome'],
  16. "LANG_KEYPORTAL_VERSION" => $lang['keyportal_version'],
  17. "LANG_DOWNLOAD_KEYPORTAL" => $lang['download_keyportal'],
  18. ));
  19. ?>


language.php

  1. <?php
  2. $lang['powered_info'] = 'Portal oparty o skrypt KeyPortal';
  3. $lang['welcome'] = 'Witamy na stronie';
  4. $lang['keyportal_version'] = 'v1.0.0';
  5. $lang['download_keyportal'] = 'Pobierz KeyPortal';
  6. ?>


functions.php

  1. <?php
  2. class template
  3. {
  4. var $theme = 'Default';
  5. var $assigned_vars = array();
  6. var $template_content = '';
  7.  
  8. function __construct() {}
  9.  
  10. function error ($message)
  11. {
  12. echo $message;
  13. }
  14.  
  15. function add_file ($template_file)
  16. {
  17. $template_path = "templates/$this->theme/$template_file";
  18.  
  19. if( file_exists ($template_path) )
  20. {
  21. $this->template_content = file_get_contents ($template_path);
  22. unset ($template_path);
  23. }
  24. else
  25. {
  26. error ("Szablon $template_file nie może zostać odnaleziony");
  27. }
  28. } 
  29.  
  30. function set_template () 
  31. {
  32. foreach ( $this->assigned_vars as $key => $value )
  33. {
  34. $this->assigned_vars[strtoupper($key)] = $value;
  35. }
  36. }
  37.  
  38. function __destruct ()
  39. {
  40. foreach ( $this->assigned_vars as $key => $value )
  41. {
  42. $this->template_content = str_replace('{'.$key.'}', $value, $this->template_content);
  43. }
  44.  
  45. echo $this->template_content;
  46. }
  47. }
  48. ?>


I mam z tym taki problem, że gdy wchodzę na stronę nie wyświetla mi templatek zainicjowanych w pliku index.php. Co mam źle?

Ten post edytował Yazzie 4.06.2007, 16:43:05
Go to the top of the page
+Quote Post
nexis
post
Post #2





Grupa: Zarejestrowani
Postów: 1 012
Pomógł: 109
Dołączył: 26.09.2003
Skąd: nexis.pl

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


Skrypt zwraca jakiś błąd? Np. "Szablon nie może zostać odnaleziony"?
Go to the top of the page
+Quote Post
Yazzie
post
Post #3





Grupa: Zarejestrowani
Postów: 37
Pomógł: 0
Dołączył: 5.04.2007
Skąd: Otwock

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


Nie, po prostu pokazuje się czysta strona.
Go to the top of the page
+Quote Post
nexis
post
Post #4





Grupa: Zarejestrowani
Postów: 1 012
Pomógł: 109
Dołączył: 26.09.2003
Skąd: nexis.pl

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


System szablonów działa prawidłowo. Upewnij się, że Twoje szablony znajdują w następującej lokalizacji:

templates/Default/header.tpl
templates/Default/index.tpl
templates/Default/footer.tpl
Go to the top of the page
+Quote Post
Yazzie
post
Post #5





Grupa: Zarejestrowani
Postów: 37
Pomógł: 0
Dołączył: 5.04.2007
Skąd: Otwock

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


No znajdują się :| Nie wiem już, co mam robić (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)
Go to the top of the page
+Quote Post
nexis
post
Post #6





Grupa: Zarejestrowani
Postów: 1 012
Pomógł: 109
Dołączył: 26.09.2003
Skąd: nexis.pl

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


Musisz gdzieś robić głupi błąd, bo u mnie wszystko ładnie działa.
Go to the top of the page
+Quote Post
Yazzie
post
Post #7





Grupa: Zarejestrowani
Postów: 37
Pomógł: 0
Dołączył: 5.04.2007
Skąd: Otwock

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


W tym problem, że wszystko (chyba) jest OK (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)
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: 23.08.2025 - 20:06