Welcome Guest, Not a member yet? Register   Sign In
How to deal with page routing in a custom CMS?
#1

[eluser]Unknown[/eluser]
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:

Code:
$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 general?
#2

[eluser]c77m[/eluser]
Set the default controller to your pagemaker controller and use a function there to check the db for matching entries. Redirect to a specific page if there is no match.

Just don't have controllers by the same name as pages, and that would work fine. (I do this for sections of my site, but the cms only affects specific paths like /news/* etc.)
#3

[eluser]Unknown[/eluser]
OK how about this example:

Code:
www.mysite.com/about

if there is no "about" controller - what happens? surely all I will get is 404 - even if there is a page record in the db.

i.e the default controller is only called when there is no URL present.
#4

[eluser]Phil Sturgeon[/eluser]
I've just answered you on StackOverflow.




Theme © iAndrew 2016 - Forum software by © MyBB