|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
scdgro Smarty Regular
Joined: 24 May 2003 Posts: 39 Location: Netherlands
|
Posted: Thu Aug 28, 2003 7:42 pm Post subject: Strange behavior of template dir |
|
|
Code: |
In file : <docroot>/classes/classes.php
class Qparse extends Smarty
{
function Qparse($tpl_dir='',$compile_dir='',$config_dir='',$cache_dir='')
{ Smarty::Smarty();
$this->template_dir = empty($tpl_dir) ? '/tmp' : $tpl_dir;
$this->compile_dir = empty($compile_dir) ? '/tmp' : $compile_dir;
$this->config_dir = empty($config_dir) ? '/tmp' : $config_dir;
$this->cache_dir = empty($cache_dir) ? '/tmp' : $cache_dir;
}
}
|
Code: |
In file <docroot>/berichten.php
define('REL_PATH','./');
include_once(REL_PATH."include/algemeen.inc.php");
system("cat ./templates/berichten.tpl"); <-- to test because of the error
$messages = new Qparse(TPL_DIR);
$messages->assign('img_subheader',IMG_DIR.'banners/subheader.jpg');
$messages->assign('txt_subheader','Berichten');
$messages->assign('bericht',$bericht_array);
$messages->assign('HEADER',$header_file);
$messages->assign('MENU',$menu_file);
$messages->assign('FOOTER',$footer_file);
$messages->display(TPL_DIR.'berichten.tpl');
|
defined in algemeen.inc.php :
define('SMARTY_DIR','/usr/lib/php/Smarty/')
define ('TPL_DIR',REL_PATH.'templates/');
Why doesn't this work. because i get the folllowing error.
Warning: Smarty error: unable to read template resource: "./templates/berichten.tpl" in /usr/lib/php/Smarty/Smarty.class.php on line 1042
The next line substituted would be :
$messages->display(TPL_DIR.'berichten.tpl'); -> $messages->display('./templates/berichten.tpl');
And it doesn't work.
every attempt to display the file , eg with the above system(cat ./templates/berichten.tpl) does work.
When I give the TPL_DIR the value of ../templates the thing works again.
Just if the dir were one level down than expected.
In short :
$messages->display('./templates/berichten.tpl'); doesn't work
$messages->display('../templates/berichten.tpl'); does work
And all suggests that the first has to work.
any thoughts ?
additional info :
there is a copy of this code running on the same machine but in a different documentroot ( 1 devel, 1 production ). could this be of some influence ?
echo ($messages->template_dir); gives ./templates |
|
Back to top |
|
scdgro Smarty Regular
Joined: 24 May 2003 Posts: 39 Location: Netherlands
|
Posted: Thu Aug 28, 2003 11:39 pm Post subject: |
|
|
Solved yeah.
Some heavy thinking and some reading of FAQs
The error did come from the copy i had.
A file subheader.tpl, was searched by smarty, so in the copy i changed the filename.
At the errorpoint the filename changed also.
That's when my light went up, they use the same compile dir, but should they use the same compile files, YES. And then i rembember a thing in the faq about using multiple instances of smarty, with the recomendation of using separate dirs also.
So i did and the problem was solved.(thankfully) |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|