Welcome Guest, Not a member yet? Register   Sign In
Categories/ Subcategories/ Articles -recursive
#1

[eluser]roadie[/eluser]
Hi guys!
I have this db structure

categories:
id|name|description|type|parent_id|status //type can be "general" or "business"

articles:
id|title|content|parent_id|status

companies:
id|name|description|content|parent_id|status

What I want to achieve is to show my categories and their children like this:

Category1 (type=general)
Subcat1
Subcat2
Subcat3 => Article1
Article2
Article3

Category2 (type=general)
Article1
Article2
Article3
---------------
CategoryX (type=business)
Subcat1
Subcat2
Subcat3 => Company1
Company2
Company3

I found lots of examples about the recursive method and made it work as long as I don't have two kinds of leafs (Articles, Companies). If the top category is "business", then the leafs will be "companies", if "general" the leafs will be simple "articles".

Should I structure my db in a different way? I have only one "business" top-category, the rest are all "general".

Help is greatly appreciate it!
#2

[eluser]InsiteFX[/eluser]
Do a forum search on my name, there is menu code that I posted that you
can make work with categories and sub-categories. It has a recursive
method.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB