|
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 |
wantho Smarty Rookie
Joined: 21 Sep 2011 Posts: 8
|
Posted: Wed Feb 01, 2012 11:51 am Post subject: Smarty extended setup |
|
|
From a blog I found on the web I managed to install Smarty basic setup, it works fine.
I now wish to progress and setup using the 'extended setup'. Code from the same source.
<?php
//load Smarty library
require('Smarty.class.php');
//The setup.php file is a good place to load
//required application library files,
//and you can do that right here. An example:
//require('guestbook/guestbook.lib.php');
class Smarty_GuestBook extends Smarty{
function Smarty_GuestBook(){
//Class Constructer.
//These automatically get set with each new instance.
$path = $_SERVER["DOCUMENT_ROOT"];
$this->Smarty();
$this->template_dir=$path.'guestbook/templates/';
$this->compile_dir =$path.'guestbook/templates_c/';
$this->config_dir =$path.'guestbook/configs/';
$this->cache_dir =$path.'guestbook/cache/';
$this->caching=true;
$this->assign('app_name','Guest Book');
}
}
?>
And here is the subsequent error, I think the error might be down to a difference in the Smarty version I have 3.1.0 and the version used in the blog.
Fatal error: Uncaught exception 'SmartyException' with message 'Call of unknown function 'Smarty'.' in C:\wamp\bin\php\php5.3.0\Smarty\libs\sysplugins\smarty_internal_templatebase.php:692 Stack trace: #0 [internal function]: Smarty_Internal_TemplateBase->__call('Smarty', Array) #1 C:\wamp\bin\php\php5.3.0\includes\guestbook\setup.php(1: Smarty_GuestBook->Smarty() #2 C:\wamp\www\guestbook\index.php(4): Smarty_GuestBook->Smarty_GuestBook() #3 {main} thrown in C:\wamp\bin\php\php5.3.0\Smarty\libs\sysplugins\smarty_internal_templatebase.php on line 692
Also should I have used the 'libs\Smarty-v.e.r\" when I installed Smarty? |
|
Back to top |
|
douglassdavis Smarty Junkie
Joined: 21 Jan 2008 Posts: 541
|
Posted: Wed Feb 01, 2012 12:02 pm Post subject: Re: Smarty extended setup |
|
|
Wherever you got the code from, it needs to be changed.
Change this:
$this->Smarty();
to
parent::__construct();
also, see
http://www.smarty.net/docs/en/installing.smarty.extended.tpl
notice the code to set the directories looks like this:
$this->setTemplateDir('/web/www.example.com/guestbook/templates/');
$this->setCompileDir('/web/www.example.com/guestbook/templates_c/');
$this->setConfigDir('/web/www.example.com/guestbook/configs/');
$this->setCacheDir('/web/www.example.com/guestbook/cache/'); |
|
Back to top |
|
wantho Smarty Rookie
Joined: 21 Sep 2011 Posts: 8
|
Posted: Wed Feb 01, 2012 9:33 pm Post subject: Extended Setup |
|
|
Hello Doug.
I followed you suggestions but before I ran it I took a chance and made one or two alterations, here's what I ended up with and it ran first time, I was more than pleased.
<?php
//load Smarty library
require('Smarty.class.php');
//The setup.php file is a good place to load
//required application library files,
//and you can do that right here. An example:
//require('guestbook/guestbook.lib.php');
class Smarty_GuestBook extends Smarty{
function __construct()
{
$path = $_SERVER["DOCUMENT_ROOT"];
// Class Constructor.
// These automatically get set with each new instance.
parent::__construct();
$this->setTemplateDir($path.'/guestbook/templates/');
$this->setCompileDir($path.'/guestbook/templates_c/');
$this->setConfigDir($path.'/guestbook/configs/');
$this->setCacheDir($path.'/guestbook/cache/');
$this->caching = Smarty::CACHING_LIFETIME_CURRENT;
$this->assign('app_name', 'Guest Book');
}
}
?> |
|
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
|