View previous topic :: View next topic |
Author |
Message |
rodolfobarretoweb Smarty Rookie
Joined: 12 Oct 2011 Posts: 8
|
Posted: Fri Oct 14, 2011 11:13 pm Post subject: Problems with extends of the class Smarty |
|
|
I'm extending the class Smarty of the library smarty and every time I instantiate the class SmartySetup it doesn't find the files that I had configured in the class and if i'm in a subdirectory returns an error saying the file required wasn't found.
Code: | <?php
require($_SERVER['DOCUMENT_ROOT']."/php/lib/smarty/libs/Smarty.class.php");
class SmartySetup extends Smarty{
public function Setup() {
$document_root = $_SERVER['DOCUMENT_ROOT'];
# seta os diretorios para o smarty
$this->template_dir = $document_root."/templates/";
$this->compile_dir = $document_root."/compile/";
$this->config_dir = $document_root."/configs/";
$this->cache_dir = $document_root."/cache/";
# define se o cache está ligado ou não
$this->caching = false;
# define o tempo para expirar o cache
$this->cache_lifetime = 10;
}
}
?>
|
My directory struct
[/img] |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Fri Oct 14, 2011 11:58 pm Post subject: |
|
|
Your templates folder is not in document_root but in php folder |
|
Back to top |
|
rodolfobarretoweb Smarty Rookie
Joined: 12 Oct 2011 Posts: 8
|
Posted: Sat Oct 15, 2011 12:22 am Post subject: |
|
|
You mean that I have to put the library in the root folder of the server? |
|
Back to top |
|
rodolfobarretoweb Smarty Rookie
Joined: 12 Oct 2011 Posts: 8
|
Posted: Sat Oct 15, 2011 12:24 am Post subject: |
|
|
Ps: my templates folder is out of php folder. You can check it. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sat Oct 15, 2011 12:25 am Post subject: |
|
|
$this->template_dir = $document_root."/PHP/templates/";
or better move the templates folder into document_root |
|
Back to top |
|
rodolfobarretoweb Smarty Rookie
Joined: 12 Oct 2011 Posts: 8
|
Posted: Sat Oct 15, 2011 12:26 am Post subject: |
|
|
|
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sat Oct 15, 2011 12:36 am Post subject: |
|
|
are you using smarty 3.x and php5? if so:
function setup() { ... $this->Smarty() ...}
should be?
function __construct() { parent::__construct(); ... } |
|
Back to top |
|
rodolfobarretoweb Smarty Rookie
Joined: 12 Oct 2011 Posts: 8
|
Posted: Sat Oct 15, 2011 12:59 am Post subject: |
|
|
Thanks man, the problem was solved. Thank you so much!
This is the solucion
Code: | <?php
require($_SERVER['DOCUMENT_ROOT']."/breakbeat/php/lib/smarty/libs/Smarty.class.php");
class SmartySetup extends Smarty{
public function __construct() {
parent::__construct();
//$this->Smarty();
# seta os diretorios para o smarty
$this->template_dir = $_SERVER['DOCUMENT_ROOT']."/breakbeat/templates/";
$this->compile_dir = $_SERVER['DOCUMENT_ROOT']."/breakbeat/compile/";
$this->config_dir = $_SERVER['DOCUMENT_ROOT']."/breakbeat/configs/";
$this->cache_dir = $_SERVER['DOCUMENT_ROOT']."/breakbeat/cache/";
# define se o cache está ligado ou não
$this->caching = false;
# define o tempo para expirar o cache
$this->cache_lifetime = 10;
}
}
?>
|
|
|
Back to top |
|
rodolfobarretoweb Smarty Rookie
Joined: 12 Oct 2011 Posts: 8
|
Posted: Sat Oct 15, 2011 1:03 am Post subject: |
|
|
Are you developer of Smarty ? |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sat Oct 15, 2011 1:31 am Post subject: |
|
|
In Smarty3 the directory setting must be done by corresponding setter function to avoid other side effects.
Code: | <?php
require($_SERVER['DOCUMENT_ROOT']."/breakbeat/php/lib/smarty/libs/Smarty.class.php");
class SmartySetup extends Smarty{
public function __construct() {
parent::__construct();
//$this->Smarty();
# seta os diretorios para o smarty
$this->setTemplateDir($_SERVER['DOCUMENT_ROOT']."/breakbeat/templates/");
$this->setCompileDir($_SERVER['DOCUMENT_ROOT']."/breakbeat/compile/");
$this->setConfigDir($_SERVER['DOCUMENT_ROOT']."/breakbeat/configs/");
$this->setCacheDir($_SERVER['DOCUMENT_ROOT']."/breakbeat/cache/");
# define se o cache está ligado ou não
$this->caching = false;
# define o tempo para expirar o cache
$this->cache_lifetime = 10;
}
}
?>
|
|
|
Back to top |
|
rodolfobarretoweb Smarty Rookie
Joined: 12 Oct 2011 Posts: 8
|
Posted: Sat Oct 15, 2011 4:07 am Post subject: |
|
|
Code: | <?php
require($_SERVER['DOCUMENT_ROOT']."/breakbeat/php/lib/smarty/libs/Smarty.class.php");
class SmartySetup extends Smarty{
public function __construct() {
parent::__construct();
$document_root = $_SERVER['DOCUMENT_ROOT']."/breakbeat/";
# seta os diretorios para o smarty
parent::setTemplateDir ($document_root."templates/");
parent::setCompileDir ($document_root."compile/");
parent::setConfigDir ($document_root."configs/");
parent::setCacheDir ($document_root."cache/");
# define se o cache está ligado ou não
$this->caching = false;
# define o tempo para expirar o cache
$this->cache_lifetime = 10;
}
}
?>
|
|
|
Back to top |
|
|