|
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 |
Bas Lee Smarty n00b
Joined: 31 Dec 2012 Posts: 2
|
Posted: Mon Dec 31, 2012 4:14 pm Post subject: Unable to read config file |
|
|
Dear all,
At the moment I am trying to install Smarty and create my first tpl and conf-files. However think something with setting the directories is going wrong. This is the class I have written to set all the dir's:
Code: |
define('MD',str_replace("\\","/",getcwd()).'/');
define('SD',MD.'Smarty/');
define('TD',MD.'templates/');
// load the Smarty-class used to render templates
require_once(SD . 'Smarty.class.php');
class template extends Smarty
{
function __construct()
{
parent::__construct();
// SMARTY TEMPLATE STUFF
$smarty = new Smarty();
$smarty->setTemplateDir(TD);
$smarty->setCompileDir(TD.'templates_c');
$smarty->setConfigDir(TD.'configs');
$smarty->setCacheDir(TD.'cache');
print_r($smarty->getConfigDir());
$this->caching = Smarty::CACHING_LIFETIME_CURRENT;
$this->assign('app_name', 'Main');
}
} |
Since I cannot create folders outside of the public folder, this is the structure I am trying to create:
Code: |
/Smarty/
/templates/
/templates/main.tpl
/templates/cache
/templates/configs
/templates/configs/main.conf
/templates/main.tpl
index.php
|
When main.tpl tries to load main.conf by: {config_load file = "main.conf"} I get the error:
Fatal error: Uncaught exception 'SmartyException' with message 'Unable to read config file 'main.conf'' in /var/www/vhosts/tiaans.nl/subdomains/*subdomain*/httpdocs/Smarty/sysplugins/smarty_internal_resource_file.php:68 etc..
Besides that Smarty keeps creating folders templates_c and cache in the main dir of my public folder.
What is going wrong here? My path seems to be correct when i print:
print_r($smarty->getConfigDir());
which results in:
/var/www/vhosts/tiaans.nl/subdomains/*subdomain*/httpdocs/templates/configs/
Could someone please help me solve this problem? I would be very grateful!
Kind regards, Bas |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Dec 31, 2012 11:35 pm Post subject: |
|
|
The error is the creation of the Smarty object within the __construct() method.
Code: | class template extends Smarty
{
function __construct()
{
parent::__construct();
$this->setTemplateDir(TD);
$this->setCompileDir(TD.'templates_c');
$this->setConfigDir(TD.'configs');
$this->setCacheDir(TD.'cache');
$this->caching = Smarty::CACHING_LIFETIME_CURRENT;
$this->assign('app_name', 'Main');
}
}
|
|
|
Back to top |
|
Bas Lee Smarty n00b
Joined: 31 Dec 2012 Posts: 2
|
Posted: Tue Jan 01, 2013 4:04 pm Post subject: |
|
|
Thank you very much! |
|
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
|