Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Unable to load template file

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
Margodth
Smarty Rookie


Joined: 28 Mar 2004
Posts: 11

PostPosted: Sat Jan 07, 2012 2:35 pm    Post subject: Unable to load template file Reply with quote

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
View user's profile Send private message
Margodth
Smarty Rookie


Joined: 28 Mar 2004
Posts: 11

PostPosted: Mon Jan 09, 2012 11:20 pm    Post subject: Reply with quote

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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Jan 09, 2012 11:52 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Margodth
Smarty Rookie


Joined: 28 Mar 2004
Posts: 11

PostPosted: Thu Mar 01, 2012 6:29 am    Post subject: Reply with quote

After a couple of days, today I came back with a solved mark! Very Happy and a new problem Twisted Evil Twisted Evil

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Thu Mar 01, 2012 7:09 pm    Post subject: Reply with quote

See www.smarty.net/forums/viewtopic.php?t=21085
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP