|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
computerboy_ Smarty n00b
Joined: 09 Jul 2014 Posts: 2
|
Posted: Wed Jul 09, 2014 4:10 pm Post subject: Where to start new Smarty |
|
|
Hello!
I'm fairly new to Codeigniter and Smarty. I've been browsing internet for last couple of hours without finding answer to my question.
I have integrated Smarty 3.1.19 with the newest Codeigniter using this tutorial. When writing something to the "home.tpl" and accessing the controller via example.com/myproject/home blank page shows up.
There is maybe something I'm missing here, but should the $smarty = new Smarty be declared somewhere? How do I go on with the integration?
Codes below
Any help is greatly appreciated.
Home.php code:
Code: | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Home extends CI_Controller
{
public function index()
{
$this->load->library( 'smartyci' );
$this->smartyci->useCached( 'home.tpl' );
$this->smartyci->display( 'home.tpl' );
}
} |
Smartyci.php:
Code: | <?php
if ( ! defined('BASEPATH') )
exit( 'No direct script access allowed' );
require_once( 'application/third_party/Smarty-3.1.19/libs/Smarty.class.php' );
class Smartyci extends Smarty
{
public function __construct()
{
parent::__construct();
$config =& get_config();
$this->caching = 1;
$this->setTemplateDir( $config['application_dir'] . 'views' );
$this->setCompileDir( $config['application_dir'] . 'third_party/Smarty-3.1.8/templates_c' );
$this->setConfigDir( $config['application_dir'] . 'third_party/Smarty-3.1.8/configs' );
$this->setCacheDir( $config['application_dir'] . 'cache' );
}
//if specified template is cached then display template and exit, otherwise, do nothing.
public function useCached( $tpl, $cacheId = null )
{
if ( $this->isCached( $tpl, $cacheId ) )
{
$this->display( $tpl, $cacheId );
exit();
}
}
} |
|
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Jul 09, 2014 10:28 pm Post subject: |
|
|
It can be permission problems.
run $this->smartyci->testInstall();
It will check the installation. |
|
Back to top |
|
computerboy_ Smarty n00b
Joined: 09 Jul 2014 Posts: 2
|
Posted: Thu Jul 10, 2014 8:00 am Post subject: |
|
|
It was a permission problem indeed. Thank you very much! So apparently "$this->load->library( 'smartyci' );"creates a new Smarty?. |
|
Back to top |
|
|
|
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
|