Categories/ Subcategories/ Articles -recursive - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Categories/ Subcategories/ Articles -recursive (/showthread.php?tid=31468) |
Categories/ Subcategories/ Articles -recursive - El Forum - 06-20-2010 [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! Categories/ Subcategories/ Articles -recursive - El Forum - 06-20-2010 [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 |