Current location: Hot Scripts Forums » Programming Languages » PHP » preorder tree traversal - AS NAVIGATION?


preorder tree traversal - AS NAVIGATION?

Reply
  #1 (permalink)  
Old 03-17-09, 02:56 PM
davestar057 davestar057 is offline
Wannabe Coder
 
Join Date: Dec 2007
Posts: 115
Thanks: 1
Thanked 1 Time in 1 Post
preorder tree traversal - AS NAVIGATION?

Hi guys,

I guess most of you are familiar with the Preorder Tree Traversal algorithm....my question is...how can I use this to creat a navigation????

I understand the theory, and how to number the hierachy of tables and can put them in MySQL and query the database etc.....

My question is how do you use this for real life, website navigation????? How doyou generate a menu, using this theory??


PLEASE PLEASE HELP....as I think I am about to smash my head against a wall!!!!!!!!!
Reply With Quote
  #2 (permalink)  
Old 03-17-09, 10:20 PM
dgreenhouse's Avatar
dgreenhouse dgreenhouse is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: San Francisco
Posts: 457
Thanks: 0
Thanked 3 Times in 3 Posts
It sounds like you're already on your way...

http://www.sitepoint.com/article/hie...data-database/

Just structure the menu items as regular hierarchies.

Something like...

HTML Code:
<table>
<thead>
<th>Parent</th><th>Child</th>
</thead>
<tr><td>NULL</td><td>Menu_Top</td></tr>
<tr><td>Menu_Top</td><td>Home</td></tr>
<tr><td>Menu_Top</td><td>About Us</td></tr>
<tr><td>Menu_Top</td><td>Products</td></tr>
<tr><td>Products</td><td>Software</td></tr>
<tr><td>Products</td><td>Hardware</td></tr>
<tr><td>Menu_Top</td><td>Articles</td></tr>
<tr><td>Articles</td><td>PHP Examples</td></tr>
<tr><td>Articles</td><td>MySQL</td></tr>
<tr><td>Menu_Top</td><td>Contact</td></tr>
</table>
I thought using an html vbCode would actually render as HTML - silly me!

Well, what I was trying to show was a hierarchical table of menu items.

Last edited by dgreenhouse; 03-17-09 at 10:22 PM.
Reply With Quote
  #3 (permalink)  
Old 03-18-09, 06:39 AM
davestar057 davestar057 is offline
Wannabe Coder
 
Join Date: Dec 2007
Posts: 115
Thanks: 1
Thanked 1 Time in 1 Post
Hi,

Thanks for your reply, I really appreciate it.

But I don’t understand how to actually implement this into a working site navigation??

I understand the Tree Traversal…and how its stored in a database…..

BUT..

How do I use this in a navigation?? Does anybody have some code for this??

Or do you just code the actual navigation by hand??


I hope you can help me here……as I cannot understand, how the Tree Traversal can actually help me in a real world situation….such as creating a menu navigation system??

THANKS AND THANKS AGAIN..for any help, I just need a little push in the right direction or a little PHP to make use of the values I have stored in a MySQL table.

David
Reply With Quote
  #4 (permalink)  
Old 03-18-09, 09:39 AM
davestar057 davestar057 is offline
Wannabe Coder
 
Join Date: Dec 2007
Posts: 115
Thanks: 1
Thanked 1 Time in 1 Post
basically....on a large site, like an ecommerce....do you automatically generate the navigation......or do you just hardcode it and point it to the correct pages...then use a 'categories system' like about to pull the correct products??
Reply With Quote
  #5 (permalink)  
Old 03-18-09, 12:08 PM
davestar057 davestar057 is offline
Wannabe Coder
 
Join Date: Dec 2007
Posts: 115
Thanks: 1
Thanked 1 Time in 1 Post
Nobody has an answer ??

Please let me know how you do a navigation for a web shop?


MANY THANKS
Reply With Quote
  #6 (permalink)  
Old 03-18-09, 03:58 PM
dgreenhouse's Avatar
dgreenhouse dgreenhouse is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: San Francisco
Posts: 457
Thanks: 0
Thanked 3 Times in 3 Posts
I think you may be putting the "cart before the horse."

I'd think the question you should be asking is: "What do I want to navigate?" vs. "How do I navigate it?".

I don't think I need to belabor the structure of a typical menuing system as we use them everyday.

For a simple answer to:
"on a large site, like an ecommerce....do you automatically generate the navigation......or do you just hardcode..."

On a large site it would be daunting; if not almost impossible, to reliably manage a dynamic menuing system. On small sites, one typically just hardcodes it.

You can look into a number of the CMS & Framework systems out there to see how they manage the menuing structure.

drupal.org, joomla.org, phpCake.org, framework.zend.com, codeigniter.com and others.

Code Igniter has some very good tutorials on their framework: http://codeigniter.com/tutorials.

Also... Google...

This search garnered many possibilities right off the bat:
http://www.google.com/search?q=php+m...ient=firefox-a

Last edited by dgreenhouse; 03-18-09 at 04:20 PM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2-3 Tree implementation ShrpSight Everything Java 2 05-23-09 08:40 AM
How to change Group Header Font in Crystal report Left Most Group Tree? majidbhutta Windows .NET Programming 0 11-08-08 03:36 AM
How to build a binary tree in assembly language? phingphing Other Languages 0 11-04-08 07:15 AM
need Java script ( Ajax) Calendar, tree, grid curtisannev Job Offers & Assistance 1 10-30-05 08:59 PM


All times are GMT -5. The time now is 08:30 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.