|
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 |
gremio10 Smarty Rookie
Joined: 28 Jan 2011 Posts: 11
|
Posted: Thu Aug 25, 2011 8:48 pm Post subject: Open the view in a folder |
|
|
Hey!, I have my folder views that have all my .tpl, but I want to separate some of my .tpl, so I created another folder, called pro, and I put my .tpl inside, and in my PHP i put ->display( "pro/questions.tpl" ); but it returns this error:
Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'questions.tpl'' in C:\xampp\htdocs\ligadedoutores\Smarty\libs\sysplugins\smarty_internal_template.php:163 Stack trace: #0 C:\xampp\htdocs\ligadedoutores\Smarty\libs\sysplugins\smarty_internal_template.php(550): Smarty_Internal_Template->isExisting(true) #1 C:\xampp\htdocs\ligadedoutores\Smarty\libs\Smarty.class.php(338): Smarty_Internal_Template->getRenderedTemplate() #2 C:\xampp\htdocs\ligadedoutores\Smarty\libs\Smarty.class.php(382): Smarty->fetch('questions.tpl', NULL, NULL, NULL, true) #3 C:\xampp\htdocs\ligadedoutores\pro\questions.php(11): Smarty->display('questions.tpl') #4 {main} thrown
Thank you |
|
Back to top |
|
androidworkz Smarty Rookie
Joined: 08 Aug 2011 Posts: 15
|
Posted: Tue Sep 13, 2011 7:25 pm Post subject: |
|
|
Two issues here... first, I think you have to pass the absolute path. How I accomplished this was to create a class that extends smarty and my own "display" method that returns the full path. Kind of like this
Code: |
// this is a very simple example.
class View extends Smarty {
public function __construct($cfg = array()) {
parent::__construct();
$this->template_dir = $cfg['template_dir'];
$this->compile_dir = $cfg['compile_dir'];
$this->config_dir = $cfg['config_dir'];
$this->cache_dir = $cfg['cache_dir'];
}
public function load($template) {
$this->display($this->template_dir.$template);
}
}
|
The second issue is the DIRECTORY_SEPARATOR constant. Since you are developing on a Windows machine you should use it. |
|
Back to top |
|
seikialice88 Smarty n00b
Joined: 22 Nov 2011 Posts: 1
|
Posted: Wed Nov 23, 2011 1:57 am Post subject: Re: Open the view in a folder |
|
|
gremio10 wrote: | Hey!, I have my folder views that have all my .tpl, but I want to separate some of my .tpl, so I created another folder, called pro, and I put my .tpl inside, and in my PHP i put ->display( "pro/questions.tpl" ); but it returns this error:
Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'questions.tpl'' in C:\xampp\htdocs\ligadedoutores\Smarty\libs\sysplugins\smarty_internal_template.php:163 Stack trace: #0 C:\xampp\htdocs\ligadedoutores\Smarty\libs\sysplugins\smarty_internal_template.php(550): Smarty_Internal_Template->isExisting(true) #1 C:\xampp\htdocs\ligadedoutores\Smarty\libs\Smarty.class.php(338): Smarty_Internal_Template->getRenderedTemplate() #2 C:\xampp\htdocs\ligadedoutores\Smarty\libs\Smarty.class.php(382): Smarty->fetch('questions.tpl', NULL, NULL, NULL, true) #3 C:\xampp\htdocs\ligadedoutores\pro\questions.php(11): Smarty->display('questions.tpl') #4 {main} thrown
Thank you |
Thanks you for the post.
__________________
Watch Hugo Online Free |
|
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
|