Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Fatal Error: Unable to load Template File 'index.tpl'
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup
View previous topic :: View next topic  
Author Message
LucaWelker
Smarty Rookie


Joined: 20 Jan 2011
Posts: 8

PostPosted: Thu Jan 20, 2011 7:50 pm    Post subject: Fatal Error: Unable to load Template File 'index.tpl' Reply with quote

Hey guys,

Iīm new, and get the first error Smile

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(Cool: 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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Jan 20, 2011 8:00 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
LucaWelker
Smarty Rookie


Joined: 20 Jan 2011
Posts: 8

PostPosted: Thu Jan 20, 2011 8:08 pm    Post subject: Re Reply with quote

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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Jan 20, 2011 9:10 pm    Post subject: Reply with quote

Get rid of:

$this->Smarty();
Back to top
View user's profile Send private message Visit poster's website
LucaWelker
Smarty Rookie


Joined: 20 Jan 2011
Posts: 8

PostPosted: Thu Jan 20, 2011 9:18 pm    Post subject: Re Reply with quote

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(Cool: 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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Jan 20, 2011 9:38 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
U.Tews
Administrator


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

PostPosted: Thu Jan 20, 2011 9:39 pm    Post subject: Reply with quote

Are you sure that $this->template_dir = '../templates'; does point to the location of 'index.tpl'? Does not look like.
Back to top
View user's profile Send private message
LucaWelker
Smarty Rookie


Joined: 20 Jan 2011
Posts: 8

PostPosted: Thu Jan 20, 2011 10:09 pm    Post subject: Reply with quote

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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Jan 20, 2011 10:16 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Jan 20, 2011 10:18 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
LucaWelker
Smarty Rookie


Joined: 20 Jan 2011
Posts: 8

PostPosted: Thu Jan 20, 2011 10:24 pm    Post subject: Reply with quote

Hey Guys,

thank you very much. Now it works! Smile the real path was "../smarty/demo/templates" the absolut path i didnīt know:)

Thanks alot:)

Greetz

LucaWelker
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Jan 20, 2011 10:30 pm    Post subject: Reply with quote

absolute path is c:/web/.../smarty/demo/templates (replace ... with real dir name)
Back to top
View user's profile Send private message Visit poster's website
LucaWelker
Smarty Rookie


Joined: 20 Jan 2011
Posts: 8

PostPosted: Thu Jan 20, 2011 10:34 pm    Post subject: RE Reply with quote

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:/ Smile.

Or am I wrong?

Greetz

LucaWelker
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Jan 20, 2011 10:35 pm    Post subject: Reply with quote

Ah yeah no c: then. I saw your FTP client and assumed winblowz.
Back to top
View user's profile Send private message Visit poster's website
LucaWelker
Smarty Rookie


Joined: 20 Jan 2011
Posts: 8

PostPosted: Thu Jan 20, 2011 10:40 pm    Post subject: Reply with quote

Hey,

okey I get my Absolutpath:

Quote:
/www/htdocs/USERNAME/web/my-domain.com/smarty/demo/templates/


Greetz

LucaWelker
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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