Welcome Guest, Not a member yet? Register   Sign In
Retrofitting App to use CodeIgniter
#14

[eluser]sophistry[/eluser]
ah, a second chdir() after the first! how polite... thanks for elucidating.

EDIT: how's this? EDIT2: removed conditionals on chdir() EDIT3: updated chdir() to use full server path to the file.

EDIT4: here's the link to the wiki with the full code and comments:
http://codeigniter.com/wiki/site_migrate/
Code:
<?php
class Site_migrate_base extends Controller {

    var $default_view_and_method = 'index';
    
    function Site_migrate_base()
    {
        parent::Controller();
    }
    
    function _remap()
    {
        $view_or_method = $this->uri->rsegment(2,$this->default_view_and_method);
        
        if (method_exists($this,$view_or_method))
        {
            $this->$view_or_method();
        }
        else
        {
            $local_view_path = rtrim($this->uri->ruri_string(),'/');
            $view_file = strtok($local_view_path, '?');
            $server_path_to_view = APPPATH.'views/';
            $view_file = (is_dir($server_path_to_view.$view_file)) ? $view_file.'/'.$this->default_view_and_method : $view_file;
            chdir(dirname($server_path_to_view.$view_file));
            $this->load->view($view_file);
            chdir(dirname(FCPATH));
        }
    }
}

/* End of file site_migrate_base.php */
/* Location: ./system/application/controllers/site_migrate_base.php */


Messages In This Thread
Retrofitting App to use CodeIgniter - by El Forum - 09-12-2008, 09:25 AM
Retrofitting App to use CodeIgniter - by El Forum - 09-12-2008, 11:37 AM
Retrofitting App to use CodeIgniter - by El Forum - 09-15-2008, 04:12 AM
Retrofitting App to use CodeIgniter - by El Forum - 09-15-2008, 04:27 AM
Retrofitting App to use CodeIgniter - by El Forum - 09-15-2008, 07:56 AM
Retrofitting App to use CodeIgniter - by El Forum - 09-16-2008, 07:01 AM
Retrofitting App to use CodeIgniter - by El Forum - 09-16-2008, 11:43 AM
Retrofitting App to use CodeIgniter - by El Forum - 09-16-2008, 12:09 PM
Retrofitting App to use CodeIgniter - by El Forum - 09-16-2008, 02:13 PM
Retrofitting App to use CodeIgniter - by El Forum - 09-17-2008, 01:37 PM
Retrofitting App to use CodeIgniter - by El Forum - 09-17-2008, 07:32 PM
Retrofitting App to use CodeIgniter - by El Forum - 09-18-2008, 10:08 AM
Retrofitting App to use CodeIgniter - by El Forum - 09-18-2008, 12:19 PM
Retrofitting App to use CodeIgniter - by El Forum - 09-18-2008, 12:30 PM



Theme © iAndrew 2016 - Forum software by © MyBB