Welcome Guest, Not a member yet? Register   Sign In
CMS with default page from database?
#1

[eluser]Sven Delle[/eluser]
Hi,
I'm trying to build a CMS with codeigniter. And I'd like to be able to set a default page for the front end in the database (via an interface - not the subject here).

I can easily query the db for the info and have the controller add the corresponding $data['page_content'] to the view. But this breaks the url, so that the menu item won't 'hilite' correctly (as the browser is not aware of the url of the default page).

How do I write a controller, that routes to the default page (typically based on a simple id number).

Something like:

Code:
public function index($page_id = NULL)
{
  if(isset($page_id) && $page_id != 0)
  {
   // get the default page from db through model
   // route to the default page
   // so the correct menu items can hilite properly (self aware system)
  }
  else
  {
   // route to the requested page
  }
  
  // TODO
}

Hope this makes sense.
#2

[eluser]InsiteFX[/eluser]
Code:
// Grab the URI segment
$page_slug = $this->uri->segment('2');

if ($page_id === FALSE)
{
    $page_id = 'home';
}
#3

[eluser]Sven Delle[/eluser]
This is what I had to do:

Code:
$id = $this->site_model->get_default_page_id();
redirect('site/index/' . $id->entry_value, 'location');




Theme © iAndrew 2016 - Forum software by © MyBB