Welcome Guest, Not a member yet? Register   Sign In
Summarize Code
#1

[eluser]breaddes[/eluser]
What is a good way to summarize Code that is needed in almost every controller? In my example it is the following:

The Validation process. Only target changes in the different controllers!
Code:
if ($this->validation->run() == FALSE){
            if($this->input->isAjax())
                $this->load->view('dialog/form', $data);
            else{
                $data['extraContent'] = 'dialog/form';
                $this->load->view($target, $data);
            }
        }
        else{
            $this->centers_model->set();
            
            if($this->input->isAjax())
                $this->load->view('dialog/success', $data);
            else{
                $data['extraContent'] = 'dialog/success';
                $this->load->view($target, $data);
            }
        }

Some Extracontent that I load in every second Controller
Code:
$this->extraHeadContent = 'something1';
$this->extraHeadContent .= 'something2';
$this->extraHeadContent .= 'something3';
$this->extraHeadContent .= 'something4';

And the other thing is, how can I autoload a the following no matter what function I call in my controller. Actually I could in a constructor, but what is if I use ajax, that only sees the function. This is what I want to do in every controller function.

Code:
$data['letters'] = $this->centers_model->get_initial_letters();




Theme © iAndrew 2016 - Forum software by © MyBB