Witam
Mam taki plik php :
<?php
// load Smarty library
require('/Apache/htdocs/PrackaMgr/smarty/libs/Smarty.class.php');
//require('/Apache/htdocs/PrackaMgr/smarty/smarty_setup.php');
$smarty = new Smarty;
$smarty->template_dir = '/Apache/htdocs/PrackaMgr/smarty/templates';
$smarty->config_dir = '/Apache/htdocs/PrackaMgr/smarty/config';
$smarty->cache_dir = '/Apache/htdocs/PrackaMgr/smarty/cache';
$smarty->compile_dir = '/Apache/htdocs/PrackaMgr/smarty/templates_c';
$smarty->assign('name','fish boy!');
$smarty->assign('surname','bad fck boy!');
$smarty->display('index.tpl');
?>
Jak widac korzysta on z szablonow Smarty i po uruchomieniu go wszystko pieknie dziala.
Teraz zeby za kazdym razem nie przepisywac dir dla smarty zrobilem sobie takie cos, co zreszta jest w manualu smarty :
<?php
// load Smarty library
require('/Apache/htdocs/PrackaMgr/smarty/libs/Smarty.class.php');
// The setup.php file is a good place to load
// required application library files, and you
// can do that right here. An example:
// require('guestbook/guestbook.lib.php');
class Smarty_Setup extends Smarty {
function __construct() {
// Class Constructor.
// These automatically get set with each new instance.
$this->Smarty();
$smarty->template_dir = '/Apache/htdocs/PrackaMgr/smarty/templates';
$smarty->config_dir = '/Apache/htdocs/PrackaMgr/smarty/config';
$smarty->cache_dir = '/Apache/htdocs/PrackaMgr/smarty/cache';
$smarty->compile_dir = '/Apache/htdocs/PrackaMgr/smarty/templates_c';
//$this->caching = true;
}
}
?>
A nastepnie przerobilme pierwszy zaprezentowany plik w ten sposob :
<?php
// load Smarty library
//require('/Apache/htdocs/PrackaMgr/smarty/libs/Smarty.class.php');
require('/Apache/htdocs/PrackaMgr/smarty/smarty_setup.php');
$smarty = new Smarty_Setup;
$smarty->assign('name','fish boy!');
$smarty->assign('surname','bad fck boy!');
$smarty->display('index.tpl');
?>
Czyli mam odwolanie do pliku smarty_setup.php ktory tworzy klase potomka dla smarty i tam przechowuje wszystkie dir.
No i teraz po uruchomieniu pliku dostaje taki komunikat :
Cytat
Warning: Smarty error: unable to read resource: "index.tpl" in C:\Apache\htdocs\PrackaMgr\smarty\libs\Smarty.class.php on line 1093
Mimo ze wszystkie sciezki sa tak samo zdefiniowane, wszystkie potrzebne pliki sa inkludowane to wyskakuje taki blad, nie kumam tego, co moze byc nie tak ?
Ten post edytował Wolfie 4.10.2009, 16:12:07