|
-
Jan 10th, 2010, 03:30 PM
#1
Thread Starter
Hyperactive Member
Multi-level categories
Hi All
I've been searching the web for a solution to my problem but not found anything concrete. I hope someone can point me in the right direction here.
Basically I want to have multi-level categories on my site. I want to display these on my main page as you would find on a classifieds website for instance.
Probably the best method of achieving this that I've found is to have a table of categories and then have a 'parent' field. If a category has a parent field then it is one level below its parent in the hierarchy. My problem with this method is how to efficiently output the data on to my site.
eg.
Get first category.
If (no parent id) then {
output
} else {
output it after its parent id
}
How do I do that? I'm thinking maybe I could do a loop to go through all entries in the table and then put them all into an array of some sort? Then I could loop through the array and output to the page?
Does anyone have a better method or advise how I would do the above?? Ideally I would like to display child categories in alphabetical order below their parent categories.
Thanks in advance
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|