Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> templates jak w phpbb
vtuner
post
Post #1





Grupa: Zarejestrowani
Postów: 220
Pomógł: 10
Dołączył: 23.08.2005
Skąd: Łódź

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


Jak prosto zrobić aby sam kod funkcji itp. będą w samym pliku test.php natomiast caly wyglad w test.tpl w phpbb jest cos takiego:
  1. <?php
  2. $template->set_filenames(array(
  3. 'body' => 'test.tpl')
  4. );
  5. ?>


i potem odpowiednie odwolania do roznych czesci strony
  1. <?php
  2. $template->assign_vars(array(
  3. 'MARKETCONFIGINFO' => "$marketinfo",
  4. 'MARKETTABLETITLE' => "Stwórz lub Zmodyfikuj swój Market",
  5. 'S_CONFIG_ACTION' => append_sid('admin_shop.' . $phpEx),
  6. 'MARKETTITLE' => "Edycja Marketu",
  7. 'MARKETGENERAL' => $lang['conf_config'],
  8. 'MARKETSETTINGS' => $lang['conf_conf'],
  9. 'MARKETCOMMISIONS' => $lang['commissions'],
  10. 'MARKETEXPLAIN' => "Sekcja ta służy do tworzenia lub modyfikowania powstałego Marketu.",
  11. 'MARKETGLASS' => $board_config['market_glass'])
  12. );
  13. ?>


patrzylem na te wszytkie funcje assign_vars i set_filenames ale one maja odwołania w całym kodzie forum. Czy można to jakość w prostrzy sposob zrobic??
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
tiraeth
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 1 789
Pomógł: 41
Dołączył: 30.10.2003
Skąd: Wrocław

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


Wyciągnij sobie plik /includes/template.php z phpBB i zmień:

Kod
    /**
  * Generates a full path+filename for the given filename, which can either
  * be an absolute name, or a name relative to the rootdir for this Template
  * object.
  */
    function make_filename($filename)
    {
  // Check if it's an absolute or relative path.
  if (substr($filename, 0, 1) != '/')
  {
            $filename = ($rp_filename = phpbb_realpath($this->root . '/' . $filename)) ? $rp_filename : $filename;
  }

  if (!file_exists($filename))
  {
     die("Template->make_filename(): Error - file $filename does not exist");
  }

  return $filename;
    }

na
Kod
    /**
  * Generates a full path+filename for the given filename, which can either
  * be an absolute name, or a name relative to the rootdir for this Template
  * object.
  */
    function make_filename($filename)
    {
  // Check for slash in $filename or in $root
  if (substr($filename, 0, 1) != '/' && substr($this->root, -1) != '/')
  {
     // There is no / mark in both of strings
          $filename = $root . '/' . $filename;
  }
  else
  {
     // There is / mark in one of the string (or in both)
     $filename = $root . $filename;
  }

  if (!file_exists($filename))
  {
     die("Template->make_filename(): Error - file $filename does not exist");
  }

  return $filename;
    }

Chyba zadziała... potem już normalnie tak jak w phpBB:

  1. <?php
  2. include('template.php');
  3. $template = new Template;
  4. $template->set_rootdir('katalog_z_szablonami'); # Mozesz dac "/" na koncu
  5. $template->set_filenames(array('szablon.tpl' => 'szablon'));
  6.  
  7. $jakas_zmienna = 'Wartosc zmiennej';
  8.  
  9. $template->assign_vars(array(
  10. 'JAKIS_TAG' => $jakas_zmienna,
  11. 'NASTE_TAG' => date('Y-m-d H:i'), # Tutaj akurat dalem date() jako przyklad...
  12. ));
  13.  
  14. $template->pparse('szablon');
  15. $template->destroy();
  16.  
  17. ?>

Powinno działać (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
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: 3.10.2025 - 00:55