Jump to content

Need help with searching Categories


vincej

Recommended Posts

Hi - I am struggling to find a solution to a category problem.  

 
Perhaps I am over thinking this. I need to display a navigation menu in tabs so that as you tab through the hierarchy you can see the categories in the hierarchy both above and below where you currently are. 

 

 

Conceptually I found an architectural solution on Sitepoint called, Modified Preorder Tree Traversal - but it is quite complex and I was hoping for something a little easier. 

 

In simple terms I need to be able to search and display all the categories and sub categories going up or down the category hierarchy. It could be as much as 5 levels deep. 

 

My need is 3 fold: 

 

1 - starting at the root I have to find all the descendants. 

2 - if you start at the bottom of the hierarchy, I need to find all the ancestors. 

3 - Worst of all ... if you start half way down the hierarchy, I need to display both all the ancestors and all the descendants. 

 

Does anyone have some advice or resources I should consider ?? 

 

MANY MANY  Thanks ! 

 

 

 

 

Link to comment
Share on other sites

@requinix   I will rarely need to add or remove categories. And I will never only want immediate ancestors or descendants 

 

One thing that I omitted to mention is that, the number of levels will be of a fixed and known in advance. I need to go down 5 levels. so for example: 

 

Fruit -> Red -> Apples -> Californian -> Red Delicious | Galla | Jersey Mac |    -- 5 levels

 

So, if I click "Fruit" I might see "Fruit | Red |  Green | Yellow"   all in tabs  -- current Root level + the next level

 

If I click "Red"  I might see  "Fruit | Red | Californian | Mexican | Florida  all in tabs  -- 1 ancestor + next level of descendents

 

If I click "California"  I might see "Fruit | Red | Apples | Californian | Red Delicious | Galla | Jersey Mac "  -- 3 ancestors + next level of descendants

 

So the point is the customer can see where he has come from ( ancestors) and where he can go ( descendent ) and with 1 click jump straight back to "Red" if they choose. Also they can see the descendants beyond where they are as well.  

 

So I am thinking a 5 way multi-dimensional array.  

 

I can populate the array in hard code. Where I am coming unstuck is is how best to dynamically pull the correct content out of the array based on what the user clicks. 

 

 

Many Many Thanks for your Help ! 

Link to comment
Share on other sites

You're contradicting yourself...

And I will never only want immediate ancestors or descendants

So, if I click "Fruit" I might see "Fruit | Red |  Green | Yellow"   all in tabs  -- current Root level + the next level...

In those cases you do only want immediate descendants. Unless you're talking only about what is visible to the user at a given time - are you constructing the entire menu hierarchy at once and showing/hiding trees as the user accesses the menu? Edited by requinix
Link to comment
Share on other sites

Fair comment, yes, well pointed out - I will only want immediately descendants however, I do want to see all ancestors, such that t he click can jump multiple steps up the tree in one hit. 

 

 

are you constructing the entire menu hierarchy at once and showing/hiding trees as the user accesses the menu?

 

 

I'm not sure the best way to hold the data ie one node at a time or all in a single big array.

 

I have it working in a cms ( ExpressionEngine) using an extension. But I want to move off ExpressionEngine  and recreate it in PHP somewhere else. 

 

You can see it in a sandbox environment : 

 

http://jacobssoftwareanddesign.com/angelsroofing/index.php/sub_category/roofing

 

 

Many Thanks ! 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.