View previous topic :: View next topic |
Author |
Message |
LucaWelker Smarty Rookie
Joined: 20 Jan 2011 Posts: 8
|
Posted: Thu Jan 20, 2011 7:50 pm Post subject: Fatal Error: Unable to load Template File 'index.tpl' |
|
|
Hey guys,
Iīm new, and get the first error
today I started to install smarty on my Webspace. I tryed to do it like the do it in the Documentation. The Basic Installation works perfektly, but when I try to do the Extendet Setup I with the following "setup.php" code this error:
Error:
Quote: |
Fatal error: Uncaught exception 'SmartyException' with message 'Please use parent::__construct() to call parent constuctor' in /www/htdocs/w00d7fbd/smarty/Smarty.class.php:779 Stack trace: #0 [internal function]: Smarty->__call('Smarty', Array) #1 /www/htdocs/w00d7fbd/web/luca-welker.com/smarty/demo/includes/setup.php(9): Smarty_Demo->Smarty() #2 /www/htdocs/w00d7fbd/web/luca-welker.com/www/index.php(4): Smarty_Demo->Smarty_Demo() #3 {main} thrown in /www/htdocs/w00d7fbd/smarty/Smarty.class.php on line 779 |
Code:
Code: | <?php
define('SMARTY_DIR','../../../smarty/');
require SMARTY_DIR.'Smarty.class.php';
class Smarty_Demo extends Smarty
{
function Smarty_Demo()
{
$this->Smarty();
$this->template_dir = '../templates';
$this->compile_dir = '../templates_c';
$this->config_dir = '../configs';
$this->cache_dir = '../cache';
$this->caching = true;
$this->assign('app_name', 'Demo');
}
}
?> |
When I correct the Code and add __construct(), I get the following error:
Error:
Quote: |
Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'index.tpl'' in /www/htdocs/w00d7fbd/smarty/sysplugins/smarty_internal_template.php:163 Stack trace: #0 /www/htdocs/w00d7fbd/smarty/sysplugins/smarty_internal_template.php(541): Smarty_Internal_Template->isExisting(true) #1 /www/htdocs/w00d7fbd/smarty/Smarty.class.php(337): Smarty_Internal_Template->getRenderedTemplate() #2 /www/htdocs/w00d7fbd/smarty/Smarty.class.php(381): Smarty->fetch('index.tpl', NULL, NULL, NULL, true) #3 /www/htdocs/w00d7fbd/web/luca-welker.com/www/index.php(: Smarty->display('index.tpl') #4 {main} thrown in /www/htdocs/w00d7fbd/smarty/sysplugins/smarty_internal_template.php on line 163 |
Code:
Code: | <?php
define('SMARTY_DIR','../../../smarty/');
require SMARTY_DIR.'Smarty.class.php';
class Smarty_Demo extends Smarty
{
function Smarty_Demo__construct()
{
$this->Smarty();
$this->template_dir = '../templates';
$this->compile_dir = '../templates_c';
$this->config_dir = '../configs';
$this->cache_dir = '../cache';
$this->caching = true;
$this->assign('app_name', 'Demo');
}
}
?> |
I hope someone can help me:)
Sorry for my bad english, but Iīm german.
Greetz
LucaWelker |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Jan 20, 2011 8:00 pm Post subject: |
|
|
You need it like so (basic php OO stuff):
Code: | <?php
define('SMARTY_DIR','../../../smarty/');
require SMARTY_DIR.'Smarty.class.php';
class Smarty_Demo extends Smarty
{
function __construct() // NOTE CHANGE
{
parent::__construct(); // NOTE CHANGE
$this->template_dir = '../templates';
$this->compile_dir = '../templates_c';
$this->config_dir = '../configs';
$this->cache_dir = '../cache';
$this->caching = true;
$this->assign('app_name', 'Demo');
}
}
?> |
|
|
Back to top |
|
LucaWelker Smarty Rookie
Joined: 20 Jan 2011 Posts: 8
|
Posted: Thu Jan 20, 2011 8:08 pm Post subject: Re |
|
|
Hey,
thanks for your answer, yes I know.. I doesnīt work with OOP in php for a long time.
I got a new Error if I change my Code like yours.
Error:
Quote: |
Fatal error: Uncaught exception 'SmartyException' with message 'Please use parent::__construct() to call parent constuctor' in /www/htdocs/w00d7fbd/smarty/Smarty.class.php:779 Stack trace: #0 [internal function]: Smarty->__call('Smarty', Array) #1 /www/htdocs/w00d7fbd/web/luca-welker.com/smarty/demo/includes/setup.php(10): Smarty_Demo->Smarty() #2 /www/htdocs/w00d7fbd/web/luca-welker.com/www/index.php(4): Smarty_Demo->__construct() #3 {main} thrown in /www/htdocs/w00d7fbd/smarty/Smarty.class.php on line 779
|
Code: | <?php
define('SMARTY_DIR','../../../smarty/');
require SMARTY_DIR.'Smarty.class.php';
class Smarty_Demo extends Smarty
{
function __construct()
{
parent::__construct();
$this->Smarty();
$this->template_dir = '../templates';
$this->compile_dir = '../templates_c';
$this->config_dir = '../configs';
$this->cache_dir = '../cache';
$this->caching = true;
$this->assign('app_name', 'Demo');
}
}
?> |
Greetz
LucaWelker |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Jan 20, 2011 9:10 pm Post subject: |
|
|
Get rid of:
$this->Smarty(); |
|
Back to top |
|
LucaWelker Smarty Rookie
Joined: 20 Jan 2011 Posts: 8
|
Posted: Thu Jan 20, 2011 9:18 pm Post subject: Re |
|
|
Hey,
but when I delete this, I get the Same error like in first post:
Quote: |
Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'index.tpl'' in /www/htdocs/w00d7fbd/smarty/sysplugins/smarty_internal_template.php:163 Stack trace: #0 /www/htdocs/w00d7fbd/smarty/sysplugins/smarty_internal_template.php(541): Smarty_Internal_Template->isExisting(true) #1 /www/htdocs/w00d7fbd/smarty/Smarty.class.php(337): Smarty_Internal_Template->getRenderedTemplate() #2 /www/htdocs/w00d7fbd/smarty/Smarty.class.php(381): Smarty->fetch('index.tpl', NULL, NULL, NULL, true) #3 /www/htdocs/w00d7fbd/web/luca-welker.com/www/index.php(: Smarty->display('index.tpl') #4 {main} thrown in /www/htdocs/w00d7fbd/smarty/sysplugins/smarty_internal_template.php on line 163 |
My Code is the same but with uncommented "$this->smarty()"
I wonder, becaus in the Documentation they write it the way i did it before.
Greetz
LucaWelker |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Jan 20, 2011 9:38 pm Post subject: |
|
|
Unable to load template file 'index.tpl'
means your template_dir is probably not setup correctly, or index.tpl is missing or unreadable. most likely template_dir setting. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Jan 20, 2011 9:39 pm Post subject: |
|
|
Are you sure that $this->template_dir = '../templates'; does point to the location of 'index.tpl'? Does not look like. |
|
Back to top |
|
LucaWelker Smarty Rookie
Joined: 20 Jan 2011 Posts: 8
|
Posted: Thu Jan 20, 2011 10:09 pm Post subject: |
|
|
Hey,
Yes, Iīm sure: Here is a Picture of my FTP-Server:
and the File index.tpl exists definitly in templates.
Greetz
LucaWelker |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Jan 20, 2011 10:16 pm Post subject: |
|
|
Try using an absolute filepath for the template_dir: c:/web/....
see if that clears it up. if so, your relative path is not working. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Jan 20, 2011 10:18 pm Post subject: |
|
|
The relative dir will be relative to the executing script, so looking at your directory structure, the template_dir setting may need to be ../smarty/demo/templates or just use the absolute system filepath to be sure. |
|
Back to top |
|
LucaWelker Smarty Rookie
Joined: 20 Jan 2011 Posts: 8
|
Posted: Thu Jan 20, 2011 10:24 pm Post subject: |
|
|
Hey Guys,
thank you very much. Now it works! the real path was "../smarty/demo/templates" the absolut path i didnīt know:)
Thanks alot:)
Greetz
LucaWelker |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Jan 20, 2011 10:30 pm Post subject: |
|
|
absolute path is c:/web/.../smarty/demo/templates (replace ... with real dir name) |
|
Back to top |
|
LucaWelker Smarty Rookie
Joined: 20 Jan 2011 Posts: 8
|
Posted: Thu Jan 20, 2011 10:34 pm Post subject: RE |
|
|
Its not my own Server... I hostet by all-inkl.com ...
And its an Linux-Server... so the absolut path couldnīt start with c:/ .
Or am I wrong?
Greetz
LucaWelker |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Jan 20, 2011 10:35 pm Post subject: |
|
|
Ah yeah no c: then. I saw your FTP client and assumed winblowz. |
|
Back to top |
|
LucaWelker Smarty Rookie
Joined: 20 Jan 2011 Posts: 8
|
Posted: Thu Jan 20, 2011 10:40 pm Post subject: |
|
|
Hey,
okey I get my Absolutpath:
Quote: | /www/htdocs/USERNAME/web/my-domain.com/smarty/demo/templates/ |
Greetz
LucaWelker |
|
Back to top |
|
|