Posted: Sun Jan 14, 2007 5:30 pm
Thanks, feyd. I guess there's no real advantage to using my function approach. Instead I'd first put the incoming arrays into one big array like your $test.
Which leads me to ole's question. See, I'm trying to create a phplinks like system where users could specify whatever sub-categories they want using a symbol (e.g. "=>").
So a user could, for example, specify they want their link to be under "category1=>sub-category1=>sub-sub-category1=>sub-sub-sub-category1". That whole line would be that link's MySQL entry for category.
Get it? That way I get sub-categories on demand instead of having to define only a certain number of levels beforehand.
So what I want to do is have a loop that goes over the category entires. That means each category "line", as shown above, would be exploded (using "=>") into an array inside $test. Then I'd run the foreach and $menu would contain a tree of categories and sub-categories.
If you're in the main page, I would then present just level 0 categories and each of their first three (I think three is enough) level1 categories.
If you're inside a certain levelX category, I would present a link to its parent level(X-1) category, and the first three level(X+1) categories of that certain category.
Here are the problems so far:
1) How do I quickly unset any category that isn't level(X-1) or among the first 3 level(X+1) categories?
2) How do I store any information inside the tree (I have a links' count I want to store for each category)?
3) If I do that, how do I add the count of each sub-category to each parent category?
Which leads me to ole's question. See, I'm trying to create a phplinks like system where users could specify whatever sub-categories they want using a symbol (e.g. "=>").
So a user could, for example, specify they want their link to be under "category1=>sub-category1=>sub-sub-category1=>sub-sub-sub-category1". That whole line would be that link's MySQL entry for category.
Get it? That way I get sub-categories on demand instead of having to define only a certain number of levels beforehand.
So what I want to do is have a loop that goes over the category entires. That means each category "line", as shown above, would be exploded (using "=>") into an array inside $test. Then I'd run the foreach and $menu would contain a tree of categories and sub-categories.
If you're in the main page, I would then present just level 0 categories and each of their first three (I think three is enough) level1 categories.
If you're inside a certain levelX category, I would present a link to its parent level(X-1) category, and the first three level(X+1) categories of that certain category.
Here are the problems so far:
1) How do I quickly unset any category that isn't level(X-1) or among the first 3 level(X+1) categories?
2) How do I store any information inside the tree (I have a links' count I want to store for each category)?
3) If I do that, how do I add the count of each sub-category to each parent category?