Welcome Guest, Not a member yet? Register   Sign In
/admin and relative paths
#1

[eluser]Kunzilla[/eluser]
I work with CI 2.x and i created a backend (/admin) in my application. All works fine! But, i must set the subdir /admin in every method.

for example:
Code:
$this->load->model('admin/user_model');

what i want:
Code:
$this->load->model('user_model');

Can i set the /admin subdir as default url / path for my backend?

Thanks
#2

[eluser]InsiteFX[/eluser]
Code:
private $user_model = 'admin/user_model';

$this->load->model($user_model);
#3

[eluser]Kunzilla[/eluser]
How can i set this value global for all classes?
#4

[eluser]InsiteFX[/eluser]
Create a helper file!

Something like this:
Code:
// some place in your admin section.
public $user_model = 'admin/user_model';

// application/helpers/admin_helper.php
if ( ! function_exists('get_user_model'))
    function get_user_model()
    {
        $CI =& get_instance();
        // were ever you save the variable with the class name example: admin.
        return $CI->admin->$user_model;
    }
}

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB