Reputation: 51
I have a problem with connecting CI and Smarty. I make everything in this manual, but when I try open a page I see:
Fatal error: Uncaught --> Smarty: Unable to load template file 'view/index.tpl' <-- thrown in /opt/lampp/htdocs/ci/application/libraries/smarty/libs/sysplugins/smarty_internal_templatebase.php on line 129
Where I can change destination folder?
I also want to add, that I made a view file in the views folder.
Upvotes: 0
Views: 2307
Reputation: 596
That manual is for CodeIgniter 2. Update to CodeIgniter 3 and follow these steps:
Create 'Custom_smarty.php' file in 'application/libraries' and add this code:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH.'third_party/smarty/Smarty.class.php');
class Custom_smarty extends Smarty {
function __construct()
{
parent::__construct();
$this->setTemplateDir(APPPATH.'views/templates/');
$this->setCompileDir(APPPATH.'views/templates_c/');
}
}
?>
Create 'templates' & 'templates_c' folders inside 'application/views' folder
Open 'autoload.php' in 'application/config' folder and add:
$autoload['libraries'] = array('custom_smarty');
Inside a controller write $this->custom_smarty->display('test.tpl');
sudo chmod -R 777 templates_c
. Otherwhise contact your hosting service, if you catch the error Unable to write file. First be sure templates_c folder exists.Upvotes: 4
Reputation: 51
Ok, i find. It's view/templates but i have a new error message.
Fatal error: Uncaught --> Smarty: unable to write file application/views/compiled/wrt549692a6e7c983_16652543 <-- thrown in /opt/lampp/htdocs/ci/application/libraries/smarty/libs/sysplugins/smarty_internal_write_file.php on line 46
I create a view/compiled folder but smarty cant make file them(?) perrmissions(?)
EDIT. Ok, all is ok. I dont have permissions for few folders.
Upvotes: 0