View previous topic :: View next topic |
Author |
Message |
mani Smarty Rookie
Joined: 29 Dec 2012 Posts: 5
|
Posted: Fri Jan 11, 2013 5:57 pm Post subject: Fatal error: Uncaught exception 'SmartyCompilerException' |
|
|
ERRNO: 8
TEXT: Indirect modification of overloaded property Application::$plugins_dir has no effect
LOCATION: C:\xampp\htdocs\tshirtshop\presentation\application.php, line 19, at January 11, 2013, 6:52 pm
Showing backtrace:
Application.__construct() # line 20, file: C:\xampp\htdocs\tshirtshop\index.php
ERRNO: 8
TEXT: Indirect modification of overloaded property Application::$plugins_dir has no effect
LOCATION: C:\xampp\htdocs\tshirtshop\presentation\application.php, line 20, at January 11, 2013, 6:52 pm
Showing backtrace:
Application.__construct() # line 20, file: C:\xampp\htdocs\tshirtshop\index.php
***index.php
<?php
// Include utility files
require_once 'include/config.php';
require_once BUSINESS_DIR . 'error_handler.php';
// Set the error handler
ErrorHandler::SetHandler();
// Load the application page template
require_once PRESENTATION_DIR . 'application.php';
require_once PRESENTATION_DIR . 'link.php';
// Load the database handler
require_once BUSINESS_DIR . 'database_handler.php';
// Load Business Tier
require_once BUSINESS_DIR . 'catalog.php';
// Load Smarty template file
$application = new Application();
// Display the page
$application->display('store_front.tpl');
// Close database connection
DatabaseHandler::Close();
?>
***application.php
<?php
// Reference Smarty library
require_once SMARTY_DIR . 'Smarty.class.php';
/* Class that extends Smarty, used to process and display Smarty
files */
class Application extends Smarty
{
// Class constructor
public function __construct()
{
// Call Smarty's constructor
parent::__construct();
// Change the default template directories
$this->template_dir = TEMPLATE_DIR;
$this->compile_dir = COMPILE_DIR;
$this->config_dir = CONFIG_DIR;
$this->plugins_dir[0] = SMARTY_DIR . 'plugins';
$this->plugins_dir[1] = PRESENTATION_DIR . 'smarty_plugins';
}
}
?>
*********************************************************
Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "C:\xampp\htdocs\tshirtshop\presentation\templates\store_front.tpl" on line 3 "{load_presentation_object filename='store_front' assign='obj'}" unknown tag "load_presentation_object"' in C:\xampp\htdocs\tshirtshop\libs\smarty\sysplugins\smarty_internal_templatecompilerbase.php:657 Stack trace: #0 C:\xampp\htdocs\tshirtshop\libs\smarty\sysplugins\smarty_internal_templatecompilerbase.php(443): Smarty_Internal_TemplateCompilerBase->trigger_template_error('unknown tag "lo...', 3) #1 C:\xampp\htdocs\tshirtshop\libs\smarty\sysplugins\smarty_internal_templateparser.php(2388): Smarty_Internal_TemplateCompilerBase->compileTag('load_presentati...', Array) #2 C:\xampp\htdocs\tshirtshop\libs\smarty\sysplugins\smarty_internal_templateparser.php(3101): Smarty_Internal_Templateparser->yy_r36() #3 C:\xampp\htdocs\tshirtshop\libs\smarty\sysplugins\smarty_internal_templateparser.php(3201): Smarty_Internal_Templatep in C:\xampp\htdocs\tshirtshop\libs\smarty\sysplugins\smarty_internal_templatecompilerbase.php on line 657
***I have specified a .tpl file in disply() function// as display(store_front.tpl)
***The store_front.tpl looks like this
{* smarty *}
{config_load file="site.conf"}
{load_presentation_object filename="store_front" assign="obj"}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>{#site_title#}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link type="text/css" rel="stylesheet"
href="{$obj->mSiteUrl}styles/tshirtshop.css" />
</head>
<body>
<div id="doc" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<div id="header" class="yui-g">
<a href="{$obj->mSiteUrl}">
<img src="{$obj->mSiteUrl}images/tshirtshop.png"
alt="tshirtshop logo" />
</a>
</div>
<div id="contents" class="yui-g">
Place contents here
</div>
</div>
</div>
<div class="yui-b">
{include file="departments_list.tpl"}
</div>
</div>
</div>
</body>
</html> |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
|
Back to top |
|
mani Smarty Rookie
Joined: 29 Dec 2012 Posts: 5
|
Posted: Fri Jan 11, 2013 7:03 pm Post subject: |
|
|
Here are the index.php and application.php files
***index.php
<?php
// Include utility files
require_once 'include/config.php';
require_once BUSINESS_DIR . 'error_handler.php';
// Set the error handler
ErrorHandler::SetHandler();
// Load the application page template
require_once PRESENTATION_DIR . 'application.php';
require_once PRESENTATION_DIR . 'link.php';
// Load the database handler
require_once BUSINESS_DIR . 'database_handler.php';
// Load Business Tier
require_once BUSINESS_DIR . 'catalog.php';
// Load Smarty template file
$application = new Application();
// Display the page
$application->display('store_front.tpl');
// Close database connection
DatabaseHandler::Close();
?>
***application.php
<?php
// Reference Smarty library
require_once SMARTY_DIR . 'Smarty.class.php';
/* Class that extends Smarty, used to process and display Smarty
files */
class Application extends Smarty
{
// Class constructor
public function __construct()
{
// Call Smarty's constructor
parent::__construct();
// Change the default template directories
$this->template_dir = TEMPLATE_DIR;
$this->compile_dir = COMPILE_DIR;
$this->config_dir = CONFIG_DIR;
$this->plugins_dir[0] = SMARTY_DIR . 'plugins';
$this->plugins_dir[1] = PRESENTATION_DIR . 'smarty_plugins';
}
}
?> |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Fri Jan 11, 2013 7:52 pm Post subject: |
|
|
Ah, since Smarty 3.1 you can not any longer assign the directory properties directly. You must use the setter methods like $this->setTemplateDir(), $this->setPluginsDir() ... etc.
Like in the example link I posted earlier |
|
Back to top |
|
mani Smarty Rookie
Joined: 29 Dec 2012 Posts: 5
|
Posted: Fri Jan 11, 2013 8:10 pm Post subject: |
|
|
Hi, Thanks however, when I change it to;
$this->setTemplate_dir() = TEMPLATE_DIR;
$this->setCompile_dir() = COMPILE_DIR;
$this->setConfig_dir() = CONFIG_DIR;
$this->setPlugins_dir[0] = SMARTY_DIR . 'plugins';
$this->setPlugins_dir[1] = PRESENTATION_DIR . 'smarty_plugins';
it gives the following error
Fatal error: Can't use method return value in write context in C:\xampp\htdocs\tshirtshop\presentation\application.php on line 21
Here's folder structure:
tshirtshop/include/
tshirtshop/include/configs/
tshirtshop/libs/
tshirtshop/libs/smarty/sysplugins/
tshirtshop/libs/smarty/plugins/
tshirtshop/presentation/templates/
tshirtshop/presentation/templates_c/ |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Fri Jan 11, 2013 8:25 pm Post subject: |
|
|
$this->setTemplateDir(TEMPLATE_DIR);
$this->setCompileDir(COMPILE_DIR) ;
$this->setConfigDir(CONFIG_DIR);
$this->setPluginsDir(array(SMARTY_DIR . 'plugins,' PRESENTATION_DIR . 'smarty_plugins');
Read the documentation !!!!! |
|
Back to top |
|
mani Smarty Rookie
Joined: 29 Dec 2012 Posts: 5
|
Posted: Tue Jan 15, 2013 5:59 pm Post subject: |
|
|
Fatal error: Uncaught exception 'SmartyException' with message 'property 'template_dir' does not exist.' in C:\xampp\htdocs\tshirtshop\libs\smarty\sysplugins\smarty_internal_templatebase.php:798 Stack trace: #0 C:\xampp\htdocs\tshirtshop\presentation\application.php(14): Smarty_Internal_TemplateBase->__call('setTemplate_dir', Array) #1 C:\xampp\htdocs\tshirtshop\presentation\application.php(14): Application->setTemplate_dir('C:\xampp\htdocs...') #2 C:\xampp\htdocs\tshirtshop\index.php(20): Application->__construct() #3 {main} thrown in C:\xampp\htdocs\tshirtshop\libs\smarty\sysplugins\smarty_internal_templatebase.php on line 798 |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Jan 15, 2013 8:12 pm Post subject: |
|
|
The method name is setTemplateDir(...) not setTemplate_dir(...) |
|
Back to top |
|
|