[eluser]raiser[/eluser]
Dear Friends,
How can i reduce the code in controller? That is, is there any way to include helper files and library files only once? Now i am including individually for each and every function.
So kindly guide me to avoid this.. Here, the below code gives you an idea of what i am following the structure now...
Code:
class Events_awards extends CI_Controller{
public function _construct()
{
parents::_construct();
}
function index()
{
$this->load->helper('html');
$this->load->helper('url');
$this->load->library('session');
$this->load->library('table');
$this->load->database();
$data['title'] = "Administrator";
$this->load->view('events-awards-list', $data);
}
function add_event()
{
$this->load->helper('html');
$this->load->helper('url');
$this->load->library('session');
$this->load->helper('form');
$this->load->helper(array('form', 'url'));
$this->load->database();
$data['title'] = "Administrator";
if(!$this->input->post('submit'))
{
$this->load->view('events-awards-add', $data);
}
if($this->input->post('submit'))
{
$this->load->model('events_awards_model');
$this->events_awards_model->insert_event();
redirect('events_awards');
}
}
}
Hope you can understand the code.. If any difficulty, let me know..