Welcome Guest, Not a member yet? Register   Sign In
static page -> dynamic page in 5 minutes
#3

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



Messages In This Thread
static page -> dynamic page in 5 minutes - by El Forum - 01-23-2012, 08:20 AM
static page -> dynamic page in 5 minutes - by El Forum - 01-24-2012, 11:21 PM
static page -> dynamic page in 5 minutes - by El Forum - 01-26-2012, 08:35 AM
static page -> dynamic page in 5 minutes - by El Forum - 01-29-2012, 03:01 PM
static page -> dynamic page in 5 minutes - by El Forum - 01-29-2012, 03:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB