Database And Routes

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:

The reviews uri segment is one of the categories so it goes like this:

What would be the best way to structure my application directory as far as controllers, models, and libraries are concerned?

why create 2 tables for categories, you could have the categories table like this
category_id smallint
category_name varchar(50)
category_parent_id smallint

//the sql code
CREATE TABLE `category` (
  `category_id` smallint(6) NOT NULL AUTO_INCREMENT,
  `category_name` varchar(50) COLLATE utf8_bin NOT NULL,
  `category_parent_id` smallint(6) DEFAULT NULL,
  PRIMARY KEY (`category_id`),
  KEY `FK_category_parent_id` (`category_parent_id`),
  CONSTRAINT `FK_category_parent_id` FOREIGN KEY (`category_parent_id`) REFERENCES `category` (`category_id`) ON DELETE CASCADE ON UPDATE CASCADE
whenever category_parent_id is null that is a category, else it's a sub-category

|---Categories--| //Reviews, News, Tutorials, etc. When viewing the "news" category, url would be ---- 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 ---- function is called "subcategory" and lists all the pages under that subcategory.
Pages(pageID, subCategoryID) //News articles, xbox 360 reviews, etc... url would be ---- 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:

$route['default_controller'] = "main";
$route['scaffolding_trigger'] = "";

$route['register/activate/:any'] = 'register/activate';
$route['logout'] = 'main/logout';
/*$route['pages/news'] = 'pages/category';
$route['pages/news/:any'] = 'pages/subcategory';
$route['pages/reviews'] = "pages/category";
$route['pages/reviews/:any'] = "pages/subcategory";
$route['pages/tutorials'] = "pages/category";
$route['pages/tutorials/:any'] = "pages/subcategory";*/

$route['pages/:any'] = "pages/category";
$route['pages/:any/(:any)'] = "pages/subcategory'";

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.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.