Welcome Guest, Not a member yet? Register   Sign In
Question Regarding Views (New to CI)
#3

[eluser]tomcode[/eluser]
I've written an extension for the Loader class which allows You to keep Your templates together with the other assets outside the system :
Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* Extends the Loader Class
*
* Loads template files
*
* @package        CodeIgniter
* @subpackage    Libraries
* @author        tomcode
* @category    Loader
*/
class MY_Loader extends CI_Loader {

    /**
     * Load Template
     *
     * like the loader view method, but from app root
     *
     * @access    public
     * @param    string
     * @param    array
     * @param    bool
     * @return    string
     */
    function template($path, $vars = array(), $return = FALSE)
    {
        return $this->_ci_load(array('_ci_path' => $path.EXT, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
    }

}

Put it in application/libraries, it loads automatically.

Your file structure

themes/
theme_name/
css/
images/
php/
system/
index.php



Use it like that :
Code:
// send to browser
$this->load->template('theme_name/php/template_name', $data);

// load into variable
$template = $this->load->template('theme_name/php/template_name', $data, true);


Messages In This Thread
Question Regarding Views (New to CI) - by El Forum - 08-22-2009, 08:16 PM
Question Regarding Views (New to CI) - by El Forum - 08-23-2009, 12:22 AM
Question Regarding Views (New to CI) - by El Forum - 08-23-2009, 01:51 AM
Question Regarding Views (New to CI) - by El Forum - 08-23-2009, 06:56 AM
Question Regarding Views (New to CI) - by El Forum - 08-23-2009, 07:55 AM
Question Regarding Views (New to CI) - by El Forum - 08-24-2009, 02:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB