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

How to change the file path of smarty html to be fetch?

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


Joined: 07 Feb 2016
Posts: 2

PostPosted: Sun Feb 07, 2016 2:43 pm    Post subject: How to change the file path of smarty html to be fetch? Reply with quote

Here's my problem, I setup Codeigniter (v.3) with the use of third party (MX thingy), now I tried to integrated the Smarty (v.3) (template) with the system. Here's what I did:

1.Downloaded the latest Smarty files from smarty.net

2.Edit the autoload.php

Code:
$autoload['libraries'] = array('smarty');


3.copy the smarty files and pasted it on the application/libaries/Smarty

4.created a file smarty.php on application/libraries

Code:
 <?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

require_once( APPPATH.'libraries/Smarty/Smarty.class.php' );

class CI_Smarty extends Smarty {
public function __construct()
    {
        parent::__construct();

        $this->compile_dir =  APPPATH. "templates_c";
        $this->template_dir = VIEWPATH ;
        $this->plugins_dir = APPPATH.'libraries/smarty/plugins/';
        $this->assign( 'APPPATH', APPPATH );
        $this->assign( 'BASEPATH', BASEPATH );

        // Assign CodeIgniter object by reference to CI
        if ( method_exists( $this, 'assignByRef') )
        {
            $ci =& get_instance();
            $this->assignByRef("ci", $ci);
        }

        log_message('debug', "Smarty Class Initialized");
    }
function view($template, $data = array(), $return = FALSE)
    {
        foreach ($data as $key => $val)
        {
            $this->assign($key, $val);
        }

        if ($return == FALSE)
        {
            $CI =& get_instance();
            if (method_exists( $CI->output, 'set_output' ))
            {
                $CI->output->set_output( $this->fetch($template) );
            }
            else
            {
                $CI->output->final_output = $this->fetch($template);
            }
            return;
        }
        else
        {
            return $this->fetch($template);
        }
    }
}


5.The files and folder structure of the skin folder are these:

Code:

    skin
    '->Theme
    '-->Welcome
    '--->files (welcome_message.html)


6.My code in the welcome conteroller (application\modules\welcome\welcome.php)
Code:
class Welcome extends MX_Controller {

    function __construct()
    {
        parent::__construct();
        $this->load->model('welcome_model','welcome');
    }
    public function index()
    {
        $this->smarty->display('welcome_message.html');
    }
}


7.Now I try to Run it, but I got this error message:
Code:


         An uncaught Exception was encountered

         Type: SmartyException

         Message: Unable to load template file 'welcome_message.html'

         Filename: C:\xampp\htdocs\cleanci01\application\libraries\Smarty\sysplugins\smarty_internal_template.php

         Line Number: 139

         Backtrace:

         File: C:\xampp\htdocs\cleanci01\application\libraries\Smarty\sysplugins\smarty_internal_templatebase.php
         Line: 192
         Function: render

         File: C:\xampp\htdocs\cleanci01\application\libraries\Smarty\sysplugins\smarty_internal_templatebase.php
         Line: 109
         Function: _execute

         File: C:\xampp\htdocs\cleanci01\application\modules\welcome\Welcome.php
         Line: 14
         Function: display

         File: C:\xampp\htdocs\cleanci01\index.php
         Line: 294
         Function: require_once



I'm Not sure how will I tell smarty that he should get the file from "skin/theme/welcome/" and not in the FCPATH. How can this possibly happen?

Any help is greatly appreciated, Thanks guys!
Back to top
View user's profile Send private message
elpmis
Smarty Elite


Joined: 07 Jun 2007
Posts: 321

PostPosted: Sun Feb 07, 2016 7:23 pm    Post subject: Reply with quote

Please look here Wink

http://www.smarty.net/docs/en/api.add.template.dir.tpl
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