code Ignitor controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: code Ignitor controller (/showthread.php?tid=62673) |
code Ignitor controller - mohan7310 - 08-13-2015 <?php class Pages extends CI_Controller { public function view($page = 'home') { if ( ! file_exists('application/views/pages/'.$page.'.php')) { // Whoops, we don't have a page for that! show_404(); } $data['title'] = ucfirst($page); // Capitalize the first letter $this->load->view('templates/header', $data); $this->load->view('pages/'.$page, $data); $this->load->view('templates/footer', $data); } } This is my controller code,how should i run my code? RE: code Ignitor controller - RobertSF - 08-14-2015 Hi mohan. The functions in your controller are executed when you browse a URL that calls them. Suppose your CodeIgniter folder is called ci, and the URL to your application is http://localhost/ci. The function view in the controller Page will execute when you browse http://localhost/ci/page/view. If you browse http://localhost/ci/page/view/aboutus, the view function will receive 'aboutus' as its $page argument. This is the general behavior -- http://localhost/ci/controller/function/argument1/argument2... I hope I understood your question, so please clarify if I didn't. |