Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> systemik szabloników, Prosze o pomoc
Hpsi
post 7.06.2005, 09:17:27
Post #1





Grupa: Zarejestrowani
Postów: 483
Pomógł: 50
Dołączył: 15.03.2005
Skąd: Poznań

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


Moj problem polega na tym, że:
mam se plik skorka.php w nim klasa skorka, w niej znajdują sie metody jak poniżej. no i tam sobie pliczek index.php gdzie testuje dzialanie klasy a w nim takie cos:
  1. <?php
  2.  
  3. require_once('skorka.php');
  4. $skorka = new skorka('1'); // 1 to nazwa skorki z kotrej ma pobierac informacje.
  5. $skorka->mn_open(); 
  6. echo '1 '; // echowanie tytulu ( {tytul} )
  7. $skorka->mn_close();
  8. echo '2'; // echowanie tresco ( {textl} )
  9. $skorka->mt_close();
  10.  
  11. ?>


No i mam takie metody w klasie:

  1. <?php
  2. function mn_open() 
  3. {
  4.  global $tpl;
  5. $tp_tmp['main'] = array();
  6. } 
  7.  
  8. function mn_close() {
  9.  global $tp_tmp;
  10.  $tpl['main']['title'] = ob_get_contents();
  11. } 
  12. function mt_close() {
  13.  global $tpl;
  14.  $tpl['main']['text'] = ob_get_contents();
  15.  $tpl_file = file_get_contents('theme/'.$this->theme.'/tpl/main.tpl');
  16.  
  17.  $main = str_replace('{tytul}', $tpl['main']['title'], $tpl_file);
  18. $main = str_replace('{text}', $tpl['main']['text'], $main);
  19. return $main;
  20.  
  21. } 
  22.  
  23. ?>


ponado maly pliczek z "szablonkiem":
Kod
{tytul}<br/>
<hr>
{text}


I co mi wyswietla ? tylko "2" co tutaj skonciłem. Proszę nie polecać smartów gdyż w tym projekcjie nie moge ich użyc ... niestety ... z góry dzieki za pomoc


--------------------
Daiquiri: T1 = (dx/dt * s)^hpsi
Daiquiri: gdzie T1 - Twój czas przybycia na miejsce, dx/dt - prędkość, s droga
Daiquiri: brb trzeba by to poprawić T1 - Czas jaki Ci to zajmie
Daiquiri: Zatem T - czas dotarcia p T1 + T2 gdzie T2 = aktualny czas

===
po prostu kocham ją :D haha
Go to the top of the page
+Quote Post
nospor
post 7.06.2005, 09:22:27
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Rzucilo mi sie w oczy dwie rzeczy:
1) funkcja mn_open() - robisz global $tpl u używasz $tp_tmp
2) funckcja mn_close() - robisz global $tp_tmp a używasz $tpl


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
Hpsi
post 7.06.2005, 09:25:01
Post #3





Grupa: Zarejestrowani
Postów: 483
Pomógł: 50
Dołączył: 15.03.2005
Skąd: Poznań

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


blach moj bład, bo zmienialem kilkukrnie bo myslalem ze zmienne sie gryzly, no ale.
ale i tak nadal to nie działa :/

-- zapodac cała klase ?

Ten post edytował Hpsi+ 7.06.2005, 09:26:28


--------------------
Daiquiri: T1 = (dx/dt * s)^hpsi
Daiquiri: gdzie T1 - Twój czas przybycia na miejsce, dx/dt - prędkość, s droga
Daiquiri: brb trzeba by to poprawić T1 - Czas jaki Ci to zajmie
Daiquiri: Zatem T - czas dotarcia p T1 + T2 gdzie T2 = aktualny czas

===
po prostu kocham ją :D haha
Go to the top of the page
+Quote Post
nospor
post 7.06.2005, 09:40:49
Post #4





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




zapodaj. powiedz również jakiego efektu oczekujesz (co ma się wyświetlać)


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
Hpsi
post 7.06.2005, 11:24:30
Post #5





Grupa: Zarejestrowani
Postów: 483
Pomógł: 50
Dołączył: 15.03.2005
Skąd: Poznań

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


sorki ze dopiero teraz ale poszedłem sie zdrzemnac po całonej pracy biggrin.gif
  1. <?php
  2.  class skorka
  3.  {
  4.      var $theme;
  5.          function skorka($theme)
  6.          {
  7.              
  8.              $this->theme = $theme;
  9.          }    
  10.              
  11.          
  12.          function tpl($string, $file)
  13.          {
  14.              
  15.              $string = str_replace('{theme}', $this->theme, $string);
  16.              if($file != '')
  17.              {
  18.                  $bbmls = $GLOBALS['bbmls'];
  19.                  $bbmls->use_file($file);     
  20.                  $string = preg_replace('{[([^:}]+):([^}]+)]}e', '$bbmls->fetch('__1_2')', $string);                
  21.              }
  22.              
  23.              
  24.          }
  25.              function menu($r)
  26.              {
  27.                      $string = file_get_contents('theme/'.$this->theme.'/tpl/menu.tpl');        
  28.                      $string = str_replace('{tytul}', $r['tytul'], $string);
  29.                      $string = str_replace('{tresc}',  eval('?>'.$r['tresc'].'<?php'), $string);
  30.                      return $string;
  31.                          
  32.              }                             
  33.              
  34.                  function news($r, $kom)
  35.                  {
  36.                      $bbmls = $GLOBALS['bbmls'];
  37.                      $bbat = $GLOBALS['bbat'];
  38.                      $bbmls->use_file('news');
  39.                      $string = file_get_contents('theme/'.$this->theme.'/tpl/news.tpl');        
  40.                      $string = str_replace('{tytul}', $r['tytul'], $string);
  41.                      $string = str_replace('{tresc}',  nl2br($r['tresc']), $string);
  42.                      if($r['dtresc'] == '') {$string = str_replace('{wiecej}', '', $string);} else { $string = str_replace('{wiecej}',  '<a href=\"'.$bbat->make_link('nowosci', $r['id']).'\">'.$bbmls->fetch('__news_wiecej').' ', $string); } 
  43.                      if($bbat->get(1) == '') {$string = str_replace('{dluga:tresc}', '', $string);} else { $string = str_replace('{dluga:tresc}', nl2br($r['dtresc']), $string); }
  44.                      if($bbat->get(1) == '') {$string = str_replace('{wstecz}', '', $string);} else { $string = str_replace('{wstecz}', '<a href=\"javascript.go(-1)\">'.$bbmls->fetch('__news_wstecz').'', $string); } 
  45.                      $string = str_replace('{komentarze}', '<a href=\"'.$bbat->make_link('komenarze', 'nowosci', $id).'\">'.$bbmls->fetch('__news_komenatrze').'('.$kom.')', $string);
  46.                     return $string;                     
  47.                  }
  48.                           function mn_open() {
  49.                              global $tpl;
  50.                               ob_start();
  51.                              $tpl['main'] = array();
  52.                             
  53.                         } 
  54.                         
  55.                         function mn_close() {
  56.                              global $tpl;
  57.                              $tpl['main']['title'] = ob_get_contents();
  58.                              ob_end_clean();
  59.                                                         
  60.                         } 
  61.                         
  62.                         
  63.                         function mt_close() {
  64.                              global $tpl;
  65.                               ob_start();
  66.                              $tpl['main']['text'] = ob_get_contents();
  67.                              ob_end_clean();
  68.                          
  69.                                  $tpl_file = file_get_contents('theme/'.$this->theme.'/tpl/main.tpl');
  70.                              
  71.                                  $main = str_replace('{tytul}', $tpl['main']['title'], $tpl_file);
  72.                                  $main = str_replace('{text}', $tpl['main']['text'], $main);
  73.                                  return skorka::tpl($main, '');
  74.                                                     
  75.                         } 
  76.                                                      
  77.  }
  78. ?>

Oczekuje efektu ze zrobi mi cos takiego ze w main.tpl bede mial wyglad zwyklego działu, a w kodzie mam cos takiego
  • mam coś takiego $skorka->mn_open(); echo tytul; $skorka->mn_close(); chce zeby to co pomedzy mn_open i close zostało przezuczone do talicy $tpl['main']['title']
  • nastepnie mam pomedzy mn_close() a mt_close(); echo tresc; chce zeby to wrzucilo do tablicy $tpl['main']['title'];
  • nastpenie chce aby mn_close(); mi przefiltrowało wszystko, do pliczku mani.tpl i wyrzucilo zawartośc tpl z odpowienimi modenizacjami. w tablach chce przechowywac kod html, php itd ..
Błąd znaleźiony smile.gif
w ob_start() pokreciłem. dzięki za pomoc nospor winksmiley.jpg

Ten post edytował Hpsi+ 7.06.2005, 11:42:07


--------------------
Daiquiri: T1 = (dx/dt * s)^hpsi
Daiquiri: gdzie T1 - Twój czas przybycia na miejsce, dx/dt - prędkość, s droga
Daiquiri: brb trzeba by to poprawić T1 - Czas jaki Ci to zajmie
Daiquiri: Zatem T - czas dotarcia p T1 + T2 gdzie T2 = aktualny czas

===
po prostu kocham ją :D haha
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 15.07.2025 - 07:53