Welcome Guest, Not a member yet? Register   Sign In
Multiple subcategory levels - need routing/controller suggestions please!!
#1

[eluser]tpiscotti[/eluser]
Hello!

I'm working on a very basic product display site for a client.

Some of the products drill down to a 3rd level subcategory, so basically:

+ Main Product Categories
++ Sub Product Categories
+++ Product Series for each Product Sub Category (basically a 3rd level of sub cats)


So I need to get to that 3rd level of categories, then next comes a high-level summary page of products for that 3rd level of subcategories (which would be another URI segment) and then the product display page for a chosen product.

The whole URL ends up looking like: http://localhost/category/subcategory/su...splaybyID/

I realize this isn't anything out of the ordinary at all. It's just that I can't seem to figure out how to correctly accomplish this.

It seems in my particular situation I have to create sub-directories in my main controllers directory and additional sub-directories in there and then do some custom routing in routes.php. Too much required custom routing seems anything BUT dynamic to me -- but I'm sure I'm just completely missing something that's already built in. I'm new with CodeIgniter so I wanted to find out what the best approach would be for what I'm trying to accomplish.

Any suggestions are greatly appreciated!! If I left out any useful information you might still need, just let me know.

Thanks again in advance!
- T
#2

[eluser]davidbehler[/eluser]
Why not try this:

Controller named "category" and a function named "view" (or similiar) that takes the category, the subcategory, the subcategoryseries, the seriesproductsummary and the productdisplayid as parameters.

or am i totaly not getting what you want to do?
#3

[eluser]Tom Schlick[/eluser]
why not store each category, sub, sub sub.... in a table that stores the name and the parent ID

then in the controller call

whatever.com/controller/view/catID/category-name
#4

[eluser]tpiscotti[/eluser]
Thanks for the replies, guys!

I think you're on the right track as to what I'm hoping to achieve, but am just basically not sure how to set it up in my controller. Can you expound a bit with a simple example of a controller that I can use as a visual? It would help greatly. I know how to set up controllers in general...it's just this particular scenario of how to setup a function that will take additional parameters to drill down into deeper category levels without me having to set up additional controller pages (which I know is not the ideal solution).

trs21219 - Actually I already have tables set up as you suggested. I have each separate level of categories in their own tables (categoriesLevel1, categoriesLevel2, categoriesLevel3) and then association tables for all sub categories that are associated with other top or sub levels.

Hope this clarification helps. Let me know if you need any additional info from me.

Thank you again for your assistance! I appreciate it!

T
#5

[eluser]TheFuzzy0ne[/eluser]
The only catch with doing it this way is that you require a database call for each sub category level. Perhaps this method will help you: http://www.alandelevie.com/2008/07/12/re...-database/
#6

[eluser]pistolPete[/eluser]
Or have a look at nested sets. There are a couple of libraries for CI, e.g. MPTtree.
#7

[eluser]tpiscotti[/eluser]
Thanks, guys! I'll take a look at these.

I appreciate it!
T




Theme © iAndrew 2016 - Forum software by © MyBB