Posted 10 June 2010 - 04:01 PM
I've found a few so far (see below), but I'm wondering if anyone has any other suggestions, something they've used and would recommend? I've found quite a few examples of category tree code that are inefficient and rack up a large number of queries needlessly as they recursively build the tree, so I'm hoping to find something that's efficient or "thrifty" if you will.
I found this page that has an example that seems to fit the bill, but there's no clear example given:
http://bytes.com/top...s-subcategories (scroll down a bit)
Takes just one query and then it hands the dirty work off to PHP. This is what I'd like to do, but looking at what's there doesn't quite clue me in.
Here's a category class that also seems promising:
So...any suggestions or code snippets to share?
Posted 10 June 2010 - 04:21 PM
The DB structure to implement it is relatively easy to construct and work with. You have one table for tags (with tag ID and the actual tag), a table with the "stuff" that the tags apply to (ID and all), and a third table with two primary keys (and nothing more) - the ID of the thing, and the tag ID.
"Complex problems often have the simplest solutions" -- Not sure who said that first.
=== My projects (all feedback welcomed) ===
XML_XSLT2Processor(0.5.3) - perform XSLT 2.0 transformations in PHP.
PEAR2_Net_Transmitter(1.0.0a4) - reliable sockets.
PEAR2_Cache_SHM(0.1.2) - persistent data storage wrapper.
=== Useful tools ===
NetBeans - full featured PHP IDE, as well as a decent code editor for other things.
Fiddler2 - The best free HTTP debugger. Performance tuning, security check, integrity check, custom requests and more, all made easy.
Gobby - That's NOT my Nickname! Look at the topic.
Posted 10 June 2010 - 07:34 PM
Edited by wirehopper, 10 June 2010 - 07:37 PM.
Posted 10 June 2010 - 11:32 PM
Yes, just to display them, probably in a tabled "drill-down" format (or in a dropdown box). I just need the category generation code, I can write the back-end stuff to manage the categories (add, edit, delete).
Display only, meaning this is just to view the categories, not manage them?
Posted 11 June 2010 - 12:07 AM
If you used a SELECT statement with ORDER BY `parent_category`,`category` and then a loop through the resulting data, it might work.
The page could be .shtml or .php - including the static HTML.
Although the initial page load would have extra content, navigation through the categories would be entirely client-side, and content delivery would be limited to only the requested content, also, you could use the title tag to create a breadcrumb navigation path at the top of the page.
If you post or PM the schema - I'll think on it a bit more ...
Edited by wirehopper, 11 June 2010 - 12:08 AM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users