CodeIgniter Forums
extending CI_Loader fails in php4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: extending CI_Loader fails in php4 (/showthread.php?tid=4072)



extending CI_Loader fails in php4 - El Forum - 11-05-2007

[eluser]Arjen van Bochoven[/eluser]
I know php4 is end-of-life at the start of next year, but it might still take a long time for isp's to make the move to php5.

I ran into the following problem, I need to extend CI_Loader to accomodate a function that loads views from an arbitrary filepath:
Code:
class MY_Loader extends CI_Loader {


    // --------------------------------------------------------------------
    
    /**
     * Load View by path
     *
     *
     * @access    public     * @param    string
     * @param    array
     * @param    bool
     * @return    void
     */
    function view_fp($view, $vars = array(), $return = FALSE)
    {
        return $this->_ci_load(array('path' => $view, 'vars' => $this->_ci_object_to_array($vars), 'return' => $return));
    }

}
This works fine in php5, the problem is that the function is not available in php4 as $this->load->view_fp();

The only solution I could come up with is tangling with
Code:
/system/codeigniter/Base4.php
I changed CI_Loader to MY_Loader
Code:
class CI_Base extends MY_Loader {

    function CI_Base()
    {
        // This allows syntax like $this->load->foo() to work
        parent::MY_Loader();
        $this->load =& $this;

Does anyone have a better solution?

thnx

Arjen