View previous topic :: View next topic |
Author |
Message |
clairdelune371 Smarty n00b
Joined: 17 Oct 2011 Posts: 3
|
Posted: Mon Oct 17, 2011 9:14 pm Post subject: testInstall OK but can't load tpl |
|
|
I've got the following output:
Smarty Installation test...
Testing template directory...
/Users/xx/Sites/GFinances/smarty/templates is OK.
Testing compile directory...
/Users/xx/Sites/GFinances/smarty/templates_c is OK.
Testing plugins directory...
/usr/local/lib/Smarty-3.1.3/libs/plugins is OK.
Testing cache directory...
/Users/xx/Sites/GFinances/smarty/cache is OK.
Testing configs directory...
/Users/xx/Sites/GFinances/smarty/configs is OK.
Testing sysplugin files...
... OK
Testing plugin files...
... OK
Tests complete.
Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'index.tpl'' in /usr/local/lib/Smarty-3.1.3/libs/sysplugins/smarty_internal_templatebase.php:123 Stack trace: #0 /usr/local/lib/Smarty-3.1.3/libs/sysplugins/smarty_internal_templatebase.php(352): Smarty_Internal_TemplateBase->fetch('index.tpl', NULL, NULL, NULL, true) #1 /Users/xx/Sites/GFinances/docs/index.php(17): Smarty_Internal_TemplateBase->display('index.tpl') #2 {main} thrown in /usr/local/lib/Smarty-3.1.3/libs/sysplugins/smarty_internal_templatebase.php on line 123
and the code is:
Code: | <?php
// define our application directory
define('GFINANCE_DIR', '/Users/xx/Sites/GFinances/smarty/');
// define smarty lib directory
define('SMARTY_DIR', '/usr/local/lib/Smarty-3.1.3/libs/');
// include the setup script
include(GFINANCE_DIR . 'libs/gfinance_setup.php');
$s = new GFinances_Smarty();
$s->testInstall();
$s->display('index.tpl');
?>
<?php
require(GFINANCE_DIR . 'libs/gfinance.lib.php');
require(SMARTY_DIR . 'Smarty.class.php');
// smarty configuration
class GFinances_Smarty extends Smarty {
function __construct() {
parent::__construct();
$this->template_dir = GFINANCE_DIR . 'templates';
$this->compile_dir = GFINANCE_DIR . 'templates_c';
$this->config_dir = GFINANCE_DIR . 'configs';
$this->cache_dir = GFINANCE_DIR . 'cache';
}
}
?>
|
I have no idea why this doesn't work. Any tips appreciated.
Also, in index.php, if I just create an instance of Smarty and call display directly on that, the template loads and it all works. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Oct 17, 2011 9:41 pm Post subject: |
|
|
See the release notes. Starting with Smarty 3.1 you must use the setter functions to set up the directories.
If you set these properties directly normally the access is wrapped automatically to the setter functions. However this does not work if you extend the Smarty class.
Code: | class GFinances_Smarty extends Smarty {
function __construct() {
parent::__construct();
$this->setTemplateDir(GFINANCE_DIR . 'templates');
$this->setCompileDir(GFINANCE_DIR . 'templates_c');
$this->setConfigDir(GFINANCE_DIR . 'configs');
$this->setCache(GFINANCE_DIR . 'cache');
}
}
|
See also http://www.smarty.net/docs/en/installing.smarty.extended.tpl |
|
Back to top |
|
clairdelune371 Smarty n00b
Joined: 17 Oct 2011 Posts: 3
|
Posted: Tue Oct 18, 2011 6:57 pm Post subject: |
|
|
Thank you for the reply. However, making that change didn't affect the output. It is still giving me the exact same error message, and the testInstall is still all OK. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Oct 18, 2011 8:31 pm Post subject: |
|
|
Now it's gettiing strange. Are you really sure that index.tpl is loacted in GFINANCE_DIR . 'templates' ? |
|
Back to top |
|
Aristophan Smarty Regular
Joined: 10 Jan 2011 Posts: 96
|
Posted: Wed Oct 19, 2011 6:43 am Post subject: |
|
|
How about adding missing Dir ?
Code: | $this->setCacheDir(GFINANCE_DIR . 'cache'); |
|
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Oct 19, 2011 1:10 pm Post subject: |
|
|
Quote: | How about adding missing Dir ?
Code:
$this->setCacheDir(GFINANCE_DIR . 'cache'); |
ups
That was a typo of me |
|
Back to top |
|
clairdelune371 Smarty n00b
Joined: 17 Oct 2011 Posts: 3
|
Posted: Mon Oct 24, 2011 5:30 pm Post subject: |
|
|
I'm sure the tpl is there, like I said, if I run it on a direct $smarty instance rather than a wrapping class instance, it runs it just fine. Also the dir wasn't missing, it finds all of the correct directories in testInstall..
But...
I noticed that the server I need to run my application on doesn't have PHP 5 so I had to downgrade to Smarty 2.6.26. When I did that, it all just worked. I still haven't solved the previous problem with Smarty 3 and PHP 5 (on my local machine) but I no longer need it... |
|
Back to top |
|
karachifoods Smarty n00b
Joined: 30 Dec 2011 Posts: 1
|
Posted: Fri Dec 30, 2011 7:09 am Post subject: |
|
|
U.Tews wrote: | Now it's gettiing strange. Are you really sure that index.tpl is loacted in GFINANCE_DIR . 'templates' ? |
i dont know the other are sure or not but i perfectly sure.
sindhi biryani recipes |
|
Back to top |
|
|