Welcome Guest, Not a member yet? Register   Sign In
launch helpers with extern method
#1

hi everybody !

I'm new in PHP and codeIgniter and i have an issue with my code.
I'm trying to clean my view method by stocking some helpers in extern method.
So, instead to have:


    public function index(){
  
        $this->load->helper('url');
        $this->load->helper('form');
        $this->load->model('Users_model');
       
        $data['records'] = $this->Users_model->getData();

        $this->load->view('templates/header');
        $this->load->view('users', $data);
        $this->load->view('templates/footer');
}

i want to do this:

 public function index(){
  
        loaderMethod();
       
        $data['records'] = $this->Users_model->getData();

        $this->load->view('templates/header');
        $this->load->view('users', $data);
        $this->load->view('templates/footer');
}

    public function loaderMethod(){
        $load = array(
            "$this->load->helper('url');",
            "$this->load->helper('form');",
            "$this->load->model('Users_model');"
        );
        return $load;
    }

i know that stocking these ligns in an array it's a bad idea, but it was for show you that i'm trying to do.
If u have some ideas to give, it will be a pleasure ! Big Grin
Reply


Messages In This Thread
launch helpers with extern method - by arenholf - 07-12-2019, 03:15 AM



Theme © iAndrew 2016 - Forum software by © MyBB