Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> tpl -> podmiana styli, problem
Daimos
post
Post #1





Grupa: Zarejestrowani
Postów: 1 319
Pomógł: 118
Dołączył: 26.11.2003
Skąd: Lublin

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


witam, mam taka klase:
  1. <?php
  2.  
  3. class Template {
  4.  
  5. var $strTemplateDir = './templates/testowy';
  6. var $strBeginTag = '{';
  7. var $strEndTag = '}';
  8. var $arrVars = array();
  9. var $arrValues  = array();
  10.  
  11. function assign( $strVar, $strValue ) {
  12. $this->arrVars[]  = $this->strBeginTag . $strVar . $this->strEndTag;
  13. $this->arrValues[] = $strValue;
  14. }
  15.  
  16. function display( $strFile ) {
  17. $resFile = fopen( $this->strTemplateDir . '/' . $strFile, 'r' );
  18. $strBuff = fread( $resFile, filesize( $this->strTemplateDir . '/' . $strFile ) );
  19. $strTest = str_replace( $this->arrVars, $this->arrValues, $strBuff );
  20. echo $strTest;
  21. }
  22. }
  23. ?>


wszystko dziala ok, ale chce zrobic mozliwosc podmiany templetow, i jak zrobie cos takiego:
  1. <?php
  2.  
  3. $wybranystyl = &#092;"testowy\";
  4. class Template {
  5.  
  6. var $strTemplateDir = './templates/'.$wybranystyl; // tu jest cos nie tak
  7. var $strBeginTag = '{';
  8. var $strEndTag = '}';
  9. var $arrVars = array();
  10. var $arrValues  = array();
  11.  
  12. function assign( $strVar, $strValue ) {
  13. $this->arrVars[]  = $this->strBeginTag . $strVar . $this->strEndTag;
  14. $this->arrValues[] = $strValue;
  15. }
  16.  
  17. function display( $strFile ) {
  18. $resFile = fopen( $this->strTemplateDir . '/' . $strFile, 'r' );
  19. $strBuff = fread( $resFile, filesize( $this->strTemplateDir . '/' . $strFile ) );
  20. $strTest = str_replace( $this->arrVars, $this->arrValues, $strBuff );
  21. echo $strTest;
  22. }
  23. }
  24. ?>

to wywala bledy :/
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Daimos
post
Post #2





Grupa: Zarejestrowani
Postów: 1 319
Pomógł: 118
Dołączył: 26.11.2003
Skąd: Lublin

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


dalej mam problem ;(
bo chce pobrac z pliku tekstowego wybrany styl, robie tak:

  1. <?php
  2. $wybrany = file_get_contents(&#092;"wybrany.txt\");
  3.  
  4. $wybrany = file_get_contents(&#092;"wybrany.txt\");
  5. class Template {
  6.  
  7. global $wybrany;
  8. var $strTemplateDir = './templates/'.$wybrany;
  9. var $strBeginTag = '{';
  10. var $strEndTag = '}';
  11. var $arrVars = array();
  12.  
  13.  
  14.  
  15. ?>
i dalej wywala blad
w ten sposob rownierz blad:
  1. <?php
  2. class Template {
  3. var $wybrany = file_get_contents(&#092;"wybrany.txt\");
  4. global $wybrany;
  5. var $strTemplateDir = './templates/'.$wybrany;
  6. var $strBeginTag = '{';
  7. ?>



juz doszedlem, zrobilem jak napisales nizej:
  1. <?php
  2. var $strTemplateDir = './templates/';
  3. function Teplate( $template_dir )
  4. {
  5. $this->strTemplateDir .= $template_dir;
  6. ...
  7. }
  8.  
  9. ?>
dzieki

Ten post edytował buffalo soldier 27.05.2005, 01:47:52
Go to the top of the page
+Quote Post

Posty w temacie


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: 13.10.2025 - 17:28