Welcome Guest, Not a member yet? Register   Sign In
Overide Codeigniter ntaive library how ?
#11

[eluser]runrun[/eluser]
I still won't work, the loader class is just keeping loading views from the views folder. I guess I'm going back to 1.7.2, because this is not the only problem I'm having with CI 2.0.2
#12

[eluser]InsiteFX[/eluser]
Like I said above you may not be able to over ride the Constructor!

InsiteFX
#13

[eluser]toopay[/eluser]
[quote author="InsiteFX" date="1304344445"]You are all wrong because it is looking for an associated array!...[/quote]

Hey, what is you're talking about? Look again at Loader.php class on 'system/core', there no such thing you mention about array or associated array!
Code:
class MY_Loader extends CI_Loader {

   function __construct()
   {
   parent::construct();
   $this->_ci_view_path = APPPATH.'myown_views/';
   }

}
Save that into 'application/core', not 'application/library'! It works(tested CI 2.0.2)!
#14

[eluser]InsiteFX[/eluser]
Code:
protected $_ci_view_paths = array();

// constructor
$this->_ci_view_paths = array(APPPATH.'views/'    => TRUE);

InsiteFX
#15

[eluser]toopay[/eluser]
@InsiteFX,

Here, i include the code inside Loader.php at system/core...
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package        CodeIgniter
* @author        ExpressionEngine Dev Team
* @copyright    Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license        http://ellislab.com/codeigniter/user-guide/license.html
* @link        http://codeigniter.com
* @since        Version 1.0
* @filesource
*/

// ------------------------------------------------------------------------

/**
* Loader Class
*
* Loads views and files
*
* @package        CodeIgniter
* @subpackage    Libraries
* @author        ExpressionEngine Dev Team
* @category    Loader
* @link        http://ellislab.com/codeigniter/user-guide/libraries/loader.html
*/
class CI_Loader {

    // All these are set automatically. Don't mess with them.
    var $_ci_ob_level;
    // Here, it is string, not an array!
    var $_ci_view_path        = '';
    var $_ci_library_paths    = array();
    var $_ci_model_paths    = array();
    var $_ci_helper_paths    = array();
    var $_base_classes        = array(); // Set by the controller class
    var $_ci_cached_vars    = array();
    var $_ci_classes        = array();
    var $_ci_loaded_files    = array();
    var $_ci_models            = array();
    var $_ci_helpers        = array();
    var $_ci_varmap            = array('unit_test' => 'unit', 'user_agent' => 'agent');


    /**
     * Constructor
     *
     * Sets the path to the view files and gets the initial output buffering level
     *
     * @access    public
     */
    function __construct()
    {
        // Here, it is string, not an array!
        // If we want to specify other directory than 'views'
        // We need to declared $this->_ci_view_path = APPPATH.'otherviews/';
        // at MY_Loader.php, and save it, not into 'application/libraries' but 'application/core'
        $this->_ci_view_path = APPPATH.'views/';
        $this->_ci_ob_level  = ob_get_level();
        $this->_ci_library_paths = array(APPPATH, BASEPATH);
        $this->_ci_helper_paths = array(APPPATH, BASEPATH);
        $this->_ci_model_paths = array(APPPATH);

        log_message('debug', "Loader Class Initialized");
    }

    //... Here the view function

    /**
     * Load View
     *
     * This function is used to load a "view" file.  It has three parameters:
     *
     * 1. The name of the "view" file to be included.
     * 2. An associative array of data to be extracted for use in the view.
     * 3. TRUE/FALSE - whether to return the data or load it.  In
     * some cases it's advantageous to be able to return data so that
     * a developer can process it in some way.
     *
     * @access    public
     * @param    string
     * @param    array
     * @param    bool
     * @return    void
     */
    function view($view, $vars = array(), $return = FALSE)
    {
        return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
    }
    //...
}
So, your above code will not affecting the Loader class at all. To overide the Loader, we only need to specify our own view folder, by STRING (NOT ARRAY), at '$this->_ci_view_path' variable on MY_Loader class, then save it to application/core.
#16

[eluser]InsiteFX[/eluser]
@toopay

Quote:@InsiteFX,
Here, i include the code inside Loader.php at system/core…

So what version of CI are you talking about?
SEE! That is the problem your showing CI Reactor code not CI core code.

CI Core Version 2.0.1 and CI Version 2.0.2 not Reactor.
Code:
/**
* Loader Class
*
* Loads views and files
*
* @package        CodeIgniter
* @subpackage    Libraries
* @author        ExpressionEngine Dev Team
* @category    Loader
* @link        http://ellislab.com/codeigniter/user-guide/libraries/loader.html
*/
class CI_Loader {

    // All these are set automatically. Don't mess with them.
    protected $_ci_ob_level;
    protected $_ci_view_paths        = array();
    protected $_ci_library_paths    = array();
    protected $_ci_model_paths        = array();
    protected $_ci_helper_paths        = array();
    protected $_base_classes        = array(); // Set by the controller class
    protected $_ci_cached_vars        = array();
    protected $_ci_classes            = array();
    protected $_ci_loaded_files        = array();
    protected $_ci_models            = array();
    protected $_ci_helpers            = array();
    protected $_ci_varmap            = array('unit_test' => 'unit',
                                            'user_agent' => 'agent');

InsiteFX
#17

[eluser]toopay[/eluser]
Crap. I'm forgot we are in Core section. It just always ringing in my head, as stated at some CodeIgniter News : "When you see “CodeIgniter” by itself on this web site, it is referring to CodeIgniter Reactor."

Ok InsiteFX, i have SEE(with your bold font), what you mean now ;-)
#18

[eluser]InsiteFX[/eluser]
No problem toopay, but you can see that having the 2 different versions is very confusing!

It had me going by your code so I checked the Reactor code and then saw it.

So we were both right LOL!

I kind of stay away from the Reactor code and use the Core code!
But I do have both versions installed.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB