[eluser]Iszuddin Ismail[/eluser]
If you are creating a CMS, then let's store all the HTML in the database. And have a field that we can call url_name or slug or file_call or something. The function of that field is to become the unique caller name to be used in the URL.
And in your route, you can have something like this.
Code:
$route['page/(:any)'] = "page/view/$1";
And then your view would be something like
Code:
class Page extends CI_Controller {
public function view() {
$page_name = $this->uri->segment(2);
$the_page = $this->page_model->get_page($page_name);
if ($the_page !== false) {
$this->load->view('templates/header');
$this->load->view('pages/'.$the_page['view_to_load'], $the_page);
$this->load->view('templates/footer');
} else {
redirect('404');
}
}//view
But of course, in my example, you would need to build a page_model that handles calling page data from the database. When calling get_page using the page_model, it would return false when no page data is found.