Welcome Guest, Not a member yet? Register   Sign In
Need help in Controller
#1

[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..


Messages In This Thread
Need help in Controller - by El Forum - 05-13-2011, 12:26 AM
Need help in Controller - by El Forum - 05-13-2011, 12:39 AM
Need help in Controller - by El Forum - 05-13-2011, 01:20 AM
Need help in Controller - by El Forum - 05-13-2011, 01:34 AM
Need help in Controller - by El Forum - 05-13-2011, 04:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB