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

testInstall OK but can't load tpl

 
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 -> Installation and Setup
View previous topic :: View next topic  
Author Message
clairdelune371
Smarty n00b


Joined: 17 Oct 2011
Posts: 3

PostPosted: Mon Oct 17, 2011 9:14 pm    Post subject: testInstall OK but can't load tpl Reply with quote

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


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

PostPosted: Mon Oct 17, 2011 9:41 pm    Post subject: Reply with quote

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


Joined: 17 Oct 2011
Posts: 3

PostPosted: Tue Oct 18, 2011 6:57 pm    Post subject: Reply with quote

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


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

PostPosted: Tue Oct 18, 2011 8:31 pm    Post subject: Reply with quote

Now it's gettiing strange. Are you really sure that index.tpl is loacted in GFINANCE_DIR . 'templates' ?
Back to top
View user's profile Send private message
Aristophan
Smarty Regular


Joined: 10 Jan 2011
Posts: 96

PostPosted: Wed Oct 19, 2011 6:43 am    Post subject: Reply with quote

How about adding missing Dir ?
Code:
$this->setCacheDir(GFINANCE_DIR . 'cache');
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Wed Oct 19, 2011 1:10 pm    Post subject: Reply with quote

Quote:
How about adding missing Dir ?
Code:
$this->setCacheDir(GFINANCE_DIR . 'cache');


ups
That was a typo of me
Back to top
View user's profile Send private message
clairdelune371
Smarty n00b


Joined: 17 Oct 2011
Posts: 3

PostPosted: Mon Oct 24, 2011 5:30 pm    Post subject: Reply with quote

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


Joined: 30 Dec 2011
Posts: 1

PostPosted: Fri Dec 30, 2011 7:09 am    Post subject: Reply with quote

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
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 -> Installation and Setup 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