CodeIgniter Forums

Full Version: code Ignitor controller
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
<?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?
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.