|
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 |
Margodth Smarty Rookie
Joined: 28 Mar 2004 Posts: 11
|
Posted: Sat Jan 07, 2012 2:35 pm Post subject: Unable to load template file |
|
|
I'm not sure if it's really a bug, but I couldn't find anything in the changelogs and I couldn't solve it with the help of other topics in the forum.
I wanted to upgrade from version 3.0.8 to 3.1.7, but I got the message Unable to load template file.
So I switch to version 3.0.9 and everything works fine.
I switch again to version 3.1 and once again an error message. (diferent error message)
'SmartyException' with message 'Template './templates/main/med/header.sth' may not start with ../ or ./'' in
I've supposed that this error was related to relative paths, but 3.1 was not a point of interest. I've upgrade once more to 3.1.3 and once again Unable to load template file.
I had set a basic configuration
Code: |
class myClass {
private $_lang;
private $_template;
private $_template_cache_id;
private $_template_compile_id;
private $_template_theme;
private $_template_module;
function __construct()
{
$this->_lang = 'en';
$this->_template_theme = 'med';
$this->_template_module = 'main';
}
public function init()
{
global $conf;
// $conf['app']['templatepath'] = './templates/';
// $conf['app']['temppath'] = './temp/';
$this->_template = new Smarty();
$this->_template->cache_dir = $conf['app']['temppath'] . 'scache/';
$this->_template->setTemplateDir( $conf['app']['templatepath'] . $this->_template_theme . '/' . $this->_template_module );
$this->_template->setCompileDir( $conf['app']['temppath'] . 'scache/templates_c/' );
$this->_template_cache_id = $this->_template_theme . '-' . $this->_template_module . '-' . $this->_lang;
$this->_template_compile_id = $this->_template_theme . '-' . $this->_template_module . '-' . $this->_lang;
}
public function display( $cTemplate )
{
...
}
}
|
|
|
Back to top |
|
Margodth Smarty Rookie
Joined: 28 Mar 2004 Posts: 11
|
Posted: Mon Jan 09, 2012 11:20 pm Post subject: |
|
|
I've made use of php function realpath, but there is still the same message.
Code: | $this->_template->setTemplateDir( realpath( $conf['app']['templatepath'] . $this->_template_theme . '/' . $this->_template_module ) ); |
What I can't understand it's why in smarty docs says that there is no need of absolute paths for some configuration.
Can't understand why there is no backward compatibility on this.
Really, I had less trouble upgrading from version 2 to 3 than from 3.0 to 3.1. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Jan 09, 2012 11:52 pm Post subject: |
|
|
are you getting an error LOADING a template, or setting a config value? as for something like:
$smarty->display('./index.tpl');
(I believe) that is not allowed, just use:
$smarty->display('index.tpl');
to go relative to the template dir, or:
$smarty->display('/foo/bar/index.tpl');
for abs path (outside template dir)
inside the template dir, you can go relative to other tpl files:
{include file="./foo.tpl"} |
|
Back to top |
|
Margodth Smarty Rookie
Joined: 28 Mar 2004 Posts: 11
|
Posted: Thu Mar 01, 2012 6:29 am Post subject: |
|
|
After a couple of days, today I came back with a solved mark! and a new problem
I've always used this config: $template->setTemplateDir( './tdir/');
Before smarty 3.1 I needed to use the display method with full path:
$template->display( './tdir/header.tpl' );
Now with smarty 3.1+ I have to use:
$template->display( '.header.tpl' );
This has sense and I asume it's a bug fix so Thanks a lot.
What It's wrong now? ( using smarty 3.1.8 )
I use set_error_handler on a project.
and when the compiled file it's not already created, I have two error messages calling my function defined in set_error_handler.
Warning: filemtime() [function.filemtime]: stat failed for
and
Warning: unlink() bla bla bla...
So I have to skip these messages with a very bad example in programming.
Code: | if (( strpos( $errstr, "filemtime") !== false ) || ( strpos( $errstr, "unlink") !== false ) ) {
|
Please ....
someone enlighten me if I am wrong |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
|
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
|