• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question About Data Structure and URLs

#1
[eluser]lenwood[/eluser]
Hi All,
I'm grappling with how the data for my application is going to be structured, accessed, displayed, etc. My question comes from the URI routing info. The way CI works natively, I'd have a class named "productGroup" and then functions named "product1", etc, correct?

If I use the methods described in the URI routing document, would I be coding up classes and methods for each category of products, or can that all be created from data in the database?

Example, suppose I have shoes and boots with several choices for each. Is it possible to code up classes and methods to pull the category and product from the database? If so then adding sandals later would be pretty simple.

If this has been addressed somewhere else links are fine.

Thanks,
Chris

#2
[eluser]Colin Williams[/eluser]
The URI convention is 'controller/function/id', so that would translate in your example to 'product/category/name'

So you see you have a Product controller, category method, and the third param is the name of the specific requested category. So no, you don't need a method for every single category.

You can use routes to knock off the first part of the URI:

Code:
$route['category/(.*)'] = "product/category/$1";

Then, your URIs look like http://www.example.com/category/shoes


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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