I'm new to PHP and smarty, I don't know how to solve this. This is a rough idea about my project directory
MyProject
->include
->configs->site.conf
MyProject ->include->config.php
MyProject ->libs->smarty->plugins
MyProject ->libs->smarty->sysplugins
MyProject ->libs->smarty->debug.tpl
MyProject ->libs->smarty->Smarty.class.php
MyProject ->libs->smarty->SmartyBC.class.php
MyProject ->presentation->templates->test.tpl
MyProject ->presentation->templates_c
MyProject ->presentation->application.php
MyProject ->index.php
I have defined a variable in my site.conf file. SITE_TITLE. I'm trying to load my config file in test.tpl like this.....
{$smarty->configLoad('site.conf')}
I also tried this....
{config_load file='site.conf'}
But I'm getting this error....
Fatal error: Uncaught exception 'SmartyCompilerException' with message
'Syntax Error in template "E:\xampp\htdocs\MyProject\presentation\templates\test.tpl"
on line 1 "{$smarty.configLoad('site.conf')}" $smarty.configLoad is invalid'
in E:\xampp\htdocs\MyProject\libs\smarty\sysplugins
\smarty_internal_templatecompilerbase.php
:656 Stack trace: #0 E:\xampp\htdocs\MyProject\libs\smarty\sysplugins
\smarty_internal_compile_private_special_variable.php
(93): Smarty_Internal_TemplateCompilerBase-
>trigger_template_error('$smarty.configL...')
#1 E:\xampp\htdocs\MyProject\libs\smarty\sysplugins
\smarty_internal_templatecompilerbase.php
(473): Smarty_Internal_Compile_Private_Special_Variable
->compile(Array, Object(Smarty_Internal_SmartyTemplateCompiler),
'['configLoad']', NULL, NULL)
#2 E:\xampp\htdocs\MyProject\libs\smarty\sysplugins
\smarty_internal_templatecompilerbase.php
(247): Smarty_Internal_TemplateCompilerBase
->callTagCompiler('private_special...', Array
, '['configLoad']') #3 E:\xampp\htdocs\Cel
in E:\xampp\htdocs\Project\libs\smarty\sysplugins
\smarty_internal_templatecompilerbase.php on line 656
config.php is this....
define ( 'SITE_ROOT', dirname ( dirname ( __FILE__ ) ) );
define ( 'PRESENTATION_DIR', SITE_ROOT . '/presentation/' );
define ( 'BUSINESS_DIR', SITE_ROOT . '/business/' );
define ( 'SMARTY_DIR', SITE_ROOT . '/libs/smarty/' );
define ( 'TEMPLATE_DIR', PRESENTATION_DIR . 'templates' );
define ( 'COMPILE_DIR', PRESENTATION_DIR . 'templates_c' );
define ( 'CONFIG_DIR', '/include/configs' );
application.php is this...
require_once SMARTY_DIR . 'Smarty.class.php';
class Application extends Smarty {
public function __construct() {
parent::__construct ();
$this->template_dir = TEMPLATE_DIR;
$this->compile_dir = COMPILE_DIR;
$this->config_dir = CONFIG_DIR;
}
}
and this is my index.php...
require_once 'include/config.php';
require_once PRESENTATION_DIR . 'application.php';
$application = new Application ();
$application->display ( 'test.tpl' );
I'm using PHP 5.4.16 and smarty 3.1.10
Any suggestions are highly appreciated.