Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Unable to read config file

 
Post new topic   Reply to topic    Smarty Forum Index -> Installation and Setup
View previous topic :: View next topic  
Author Message
Bas Lee
Smarty n00b


Joined: 31 Dec 2012
Posts: 2

PostPosted: Mon Dec 31, 2012 4:14 pm    Post subject: Unable to read config file Reply with quote

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! Very Happy

Kind regards, Bas
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Mon Dec 31, 2012 11:35 pm    Post subject: Reply with quote

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


Joined: 31 Dec 2012
Posts: 2

PostPosted: Tue Jan 01, 2013 4:04 pm    Post subject: Reply with quote

Thank you very much!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    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