How to do a CMS type system |
[eluser]JanDoToDo[/eluser]
Hey guys I was wondering if you could advise the best way to do a CMS type system. I have a front controller and an admin controller both extended from MY_controller. My question is would you route everything to the front controller and then have everything in that controller for everypage and pass everything as a function and then function arguments or would you route depending on the page type to a different controller. E.g. if you had an accounts page would you setup a route to 'accounts' because it is a completely different function or would you just pass everything to front controller and have accounts as a function with arguments in that? If you routed it to different controllers what if you wanted everything to be modular or database based - if you routed using the router class you would have to add new routes everytime a new module was added? Would you also direct to the page controller and then have EVERYTHING contained in there or would you detect the uri segment and then do a redirect to the correct controller?
[eluser]Cro_Crx[/eluser]
CodeIgniter is a fairly open framework so you could do everything either of the ways your suggesting. I'd probably suggest having a controller for each type of object rather than a front controller. So if you had 'pages' and 'accounts' for example each would have their own controller. That way you only have to create routes when you need a single function to load many pages, such as a function to display a single account 'view_account' or similar. I'm assuming for your pages you'll want the URL to be www.domain.com/somepage . To achieve this you'll probably need to extend the Router class. Here's MY_Router class for the CMS system I use: Code: <?php Hope that helps
[eluser]JanDoToDo[/eluser]
Cheers for your router extension! Anyone else have any best practices of what they do?
[eluser]JanDoToDo[/eluser]
In particular, what if the class loads the same type of page, but just wants a different view for the body text for that page? Would you store an extra value in the DB for the content as like a "view type" and it could be which view you want to pull up for that page... and then that could be a selectable option when creating the content? |
Welcome Guest, Not a member yet? Register Sign In |