jest jeszcze cos jestem w trakcie rozkminiania systemu szablonów ...

  1. //TO JEST TAKI SUB TEMPLATE
  2.  
  3. <div style="background-color:#EEDEAE; width:100px; height:100px;"> {OBRAZEK[numerek]}</div>
  4. <div style="font-wieght:bolder;">{NAZWA[numerek]}</div>

  1. //A TO TAKI GŁÓWNY
  2.  
  3. <?xml version="1.0" encoding="utf-8"?>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <title>{TITLE}</title>
  8. </head>
  9. <div style="background-color:black; color:white; width=100%;"> TU BEDZIE TOP </div>
  10.  
  11. <div>MENU | MENU | MENU | MENU | </div>
  12.  
  13. <div style="background:#E0A033;">{PRODUCT}</div>
  14.  
  15.  
  16. </body>
  17. </html>


TUTAJ JEST TEN SYSTEM SZABLONÓW
  1. <?php
  2.  
  3. class view
  4. {
  5.    private $toChange;
  6.    private $str;
  7.    private $pathTemp;
  8.            
  9.    public function __construct()    
  10.    {
  11.        $this -> toChange = array();
  12.        $this -> str      = '';
  13.        $this->pathTemp='template';
  14.    }
  15.    
  16.    public function setTemplate($ATemplate)
  17.    {  
  18.        $this -> str = $ATemplate;
  19.    }      
  20.    
  21.    public function loadFromFile($FileName='def')
  22.    {  
  23.        $this -> str = file_get_contents($this->pathTemp.'/'.$FileName.'.tpl.php');
  24.    }  
  25.    
  26.    public function addChange($AKey, $AValue)
  27.    {  
  28.        $this -> toChange[$AKey] = $AValue;
  29.    }
  30.  
  31.    public function assign()
  32.    {
  33.        
  34.    }
  35.    
  36.    
  37.    public function executeChanges()
  38.    {  
  39.        if (count($this -> toChange) > 0) {
  40.            $tmpKeys = array_keys($this -> toChange);    
  41.            
  42.            foreach ($tmpKeys as $currentKey) {
  43.                $this -> str = str_replace($currentKey,
  44.                                   $this -> toChange[$currentKey],
  45.                                   $this -> str);        
  46.            }
  47.        }
  48.        return $this -> str;        
  49.    }    
  50.    
  51. }
  52.  
  53. ?>



teraz chodzi mi o pewien sposób wstrzykniecia np kilka razy tego sub template do {PRODUCT}
jak to zrobic?? oczywiscie zeby to mialo rece i nogi bo mi tylko przychodzi petala do petli petla porkryta wiec nie fajnie biggrin.gif