Database And Routes - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Database And Routes (/showthread.php?tid=26105) |
Database And Routes - El Forum - 01-06-2010 [eluser]ShoeLace1291[/eluser] I'm trying to make a content management system(CMS). I have three tables as follows: Categories - Will show up in navigational menu as News, Reviews, Tutorials, etc. SubCategories - Child of categories, under reviews would be Xbox 360, PS3, etc. Pages - Child of subcategories; under xbox 360 would be a page such as Halo 3 i have my routes set up to pick up urls like this: mysite.com/reviews/xbox-360/halo-3 The reviews uri segment is one of the categories so it goes like this: category/subcategory/page What would be the best way to structure my application directory as far as controllers, models, and libraries are concerned? Database And Routes - El Forum - 01-06-2010 [eluser]flaky[/eluser] why create 2 tables for categories, you could have the categories table like this Code: category_id smallint Database And Routes - El Forum - 01-07-2010 [eluser]ShoeLace1291[/eluser] |---Categories--| //Reviews, News, Tutorials, etc. When viewing the "news" category, url would be mysite.com/pages/news ---- function is called "category" and lists all subcategories that fall under this category. | | SubCategories(subCategoryID, categoryID) //Under a category such as reviews: Xbox 360, PS3, etc... url would be mysite.com/pages/reviews/xbox-360 ---- function is called "subcategory" and lists all the pages under that subcategory. | | Pages(pageID, subCategoryID) //News articles, xbox 360 reviews, etc... url would be mysite.com/pages/reviews/xbox-360/halo-3 ---- function is called "view" and would display the entire page. Above is a tree I created that would explain how my tables and urls are linked. I currently do not have it set up correctly which is why i'm posting this. all of the above urls are contained in a controller called pages. These page titles are all powered by databases, so I can't just make a route that reroutes pages/news to pages/category, but it would be pages/category that I would be routing to. This is my current routes config file: Code: $route['default_controller'] = "main"; You can see how I had done it prior to using the pages/:any. I can't do it that way because everytime a new category is created, I would have to create a new route. Hopefully I've explained my situation well enough for you to answer. Thanks for your time. |