How to deal with routing when developing a custom CMS in Codeigniter

Posted by Ashley Ward on Stack Overflow See other posts from Stack Overflow or by Ashley Ward
Published on 2011-01-14T12:53:47Z Indexed on 2011/01/14 13:54 UTC
Read the original article Hit count: 261

Filed under:
|
|
|
|

Hi All - I’m a recent user of Codeigniter and am developing a simple backend CMS to manage pages.

Based on a URL (in this example I have hidden “index.php”) : mysite.com/pagename

I would like the system to detect if there is a value of “pagename” in my database, if there is, I need the system to re-route to a custom controller (eg: Pagemaker) and if there is no record called pagename, just do it’s normal thing (i.e. find a controller called pagename)

Currently I have:

$route['(:any)'] = "pagemaker/create/$1"; 

whereby all requests are forwarded to my custom function.

However I want to change this structure so that if the page does NOT exist in the db, the traditional codeigniter request process is followed.

Can anyone offer any advice about how to complete this? Or any advice about routing custom CMS’s in codeigniter in general?

© Stack Overflow or respective owner

Related posts about php

Related posts about url