Forum Moderators: coopster
I want to offer my users unlimited levels and subcategories but cannot figure out how to pull them so they go into the right parent cat. I know how to pull them just not unlimited levels deep.
All of this is a little vague. Do you think you could elaborate on your idea a little as to help us help you the best we can? ;)
Aside from telling us what you want to do, could you define a subcategory, too? Unless you are meaning a subdirectory?
you could use a 'related' schema on top of the standard parent child type
when you run out of children then start working on related, as long as each major cat has 2 or more related cats then it should appear infinite
Aside from telling us what you want to do, could you define a subcategory, too? Unless you are meaning a subdirectory?" -- I meant subcategory. Example: Cars [Main category]: Honda [sub category]: Civic [sub category of a parent category]: 2DR [sub category]. I don't think it's termed as subdirectories because they aren't actual files, just navigation links. With that said I want my users to be able to add the main category [cars] and unlimited sub categories unlimited levels deep [car types, models, body types, etc...].
"do you mean how to find the url to navigate to the parent category?
how is your content organized?" -- I don't really need to find the URL rather just a way to display all of the categories under their right parent; I can do that right now but not unlimited levels deep.
"yo make it truly unlimited I would imagine that, at some point, you will need a loopback to a higher cat
you could use a 'related' schema on top of the standard parent child type
when you run out of children then start working on related, as long as each major cat has 2 or more related cats then it should appear infinite" -- A loop, function whatever would be fine; I just can't wrap my mind about how to check EVERY category for it a child then check every child for a child, etc... I'm not sure what you mean by "related schema"? I have all of my categories stored in my DB,
id, name, parent, main_category [contains "main" when the category is a main category or contains the main category for children categories]. I don't even know if this can be done but figured I'd ask around before limiting my users to a set amount of categories.
this is pretty much the 'related' premise
at some point the branch ends, therefore you need to create points higher up that you can use to select other branches that are closely related to the topic/cat/search your user is doing
this would mean that no branch ends because it is connected at it's end to at least one other branch, creating the illusion of unlimited
no matter what you do there will only ever be a finite number of cats, at some point the user will see something they have seen before
phranque has a good explanation of the basics there
another simple way to limit recursion problems is to only provided a finite number of levels of nevigation at each node. (i.e. the tree structure can be recursive but you have to navigate to see past n levels.)