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

index.tpl not found

 
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
knutsford
Smarty n00b


Joined: 22 Nov 2020
Posts: 3

PostPosted: Sun Nov 22, 2020 12:18 pm    Post subject: index.tpl not found Reply with quote

I have a files called SmartyLibrary.php in libraries under codeigniter


Code:

<?php defined('BASEPATH') OR exit('No direct script access allowed');

require_once(APPPATH . 'third_party/smarty/libs/Smarty.class.php');

class SmartyLibrary extends Smarty {

   function __construct() {
      parent::__construct();
      // Define directories, used by Smarty:
      $this->setTemplateDir(APPPATH . 'views/templates');
      $this->setCompileDir(APPPATH . 'cache');
      $this->setCacheDir(APPPATH . 'cache');
   }
}






I have

$autoload['libraries'] = array('SmartyLibrary' => 'smarty');


in autoload.php







I have an index.tpl under views/templates




I am getting

An uncaught Exception was encountered

Type: SmartyException

Message: Unable to load template 'file:index.tpl'




If I look at the Smarty array it says



[template_dir:protected] => Array
(
[0] => /var/www/vhosts/blaablaa.co.uk/httpdocs/system/templates/
)





Shouldn't it say

[template_dir:protected] => Array
(
[0] => /var/www/vhosts/blaablaa.co.uk/httpdocs/system/application/views/templates/
)


It is as though

$this->setTemplateDir(APPPATH . 'views/templates'); is being ignored


any idea what the problem is please?
Back to top
View user's profile Send private message Send e-mail
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Mon Nov 23, 2020 3:39 pm    Post subject: Reply with quote

Extending Smarty class is a bad idea.
Back to top
View user's profile Send private message
knutsford
Smarty n00b


Joined: 22 Nov 2020
Posts: 3

PostPosted: Mon Nov 23, 2020 3:57 pm    Post subject: Reply with quote

Why?


I googled and copied that bit of code or do you mean not to use smarty in the first place?
Back to top
View user's profile Send private message Send e-mail
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Tue Nov 24, 2020 5:23 am    Post subject: Reply with quote

https://en.wikipedia.org/wiki/Composition_over_inheritance
Back to top
View user's profile Send private message
knutsford
Smarty n00b


Joined: 22 Nov 2020
Posts: 3

PostPosted: Tue Nov 24, 2020 7:55 am    Post subject: Reply with quote

I am being thick but I still don't see why
Back to top
View user's profile Send private message Send e-mail
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Tue Nov 24, 2020 1:53 pm    Post subject: Reply with quote

Run
Code:
$this->testInstall();

at the end of the constructor for tests.
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
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