SitePoint Sponsor |
|
User Tag List
Results 1 to 8 of 8
Thread: Menu design?
-
Mar 5, 2007, 16:05 #1
- Join Date
- Dec 2002
- Location
- Ann Arbor, MI (USA)
- Posts
- 648
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Menu design?
I have a question in application menu design...
I'm making a program in php to handle articles/folders in a tree structure. My question is about the menu. Should this be a separate structure, with separate db tables, that links to specific folders/articles, or based on the hierarchy of folders/articles?
Thanks,
Cory
-
Mar 6, 2007, 09:18 #2
- Join Date
- Feb 2005
- Location
- Burlington, Canada
- Posts
- 2,699
- Mentioned
- 89 Post(s)
- Tagged
- 6 Thread(s)
Hi Cory,
You might want to check out this http://www.sitepoint.com/article/hierarchical-data-database Sitepoint article on storing hierarchical data in a database. It provides good theory that should help you gain a greater understanding and after reading it you will likely be able to answer your question.
Regards,
ServerStormictus=="✓"
-
Mar 6, 2007, 11:03 #3
- Join Date
- Dec 2002
- Location
- Ann Arbor, MI (USA)
- Posts
- 648
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Mar 6, 2007, 12:27 #4
- Join Date
- Feb 2005
- Location
- Burlington, Canada
- Posts
- 2,699
- Mentioned
- 89 Post(s)
- Tagged
- 6 Thread(s)
Hi Cory,
If your menus are not going to change then you might consider using a Pure C.S.S/HTML menu as the performance of this is great and you don't have to worry about any slowness in the database queries - especially when your database is getting hit hard.
However if you want to keep the menus more dynamic then it makes sense to use the existing hierarchy you have setup and building your menu from the rowdata taken from your table relationships.
I don't know if you took the time to read the article that I provided the link, but the author's explanation and examples of outputting a menu based on preorder tree traversal does show how to get the pull and traverse the data from the database into a menu. Granted he did not dress the menu output up very much, but you can do whatever you want with stylizing the strings that are output.
You would want to make sure that your menu categories have some form of integer Id and perform you SQL to join on the Id.
ServerStormictus=="✓"
-
Mar 6, 2007, 16:21 #5
- Join Date
- Dec 2002
- Location
- Ann Arbor, MI (USA)
- Posts
- 648
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I do want dynamic menus. Why does it make sense to create them from the hierarchy I already have set up, and not in a separate system?
-
Mar 6, 2007, 18:41 #6
- Join Date
- Feb 2005
- Location
- Burlington, Canada
- Posts
- 2,699
- Mentioned
- 89 Post(s)
- Tagged
- 6 Thread(s)
Hi Cory,
Why does it make sense to create them from the hierarchy I already have set up, and not in a separate system?
I am not sure what you mean bya separate system?
Most people that create dynamic menus do it in one of the following ways:- Design a database relational structure that is Traversal that allows the table relationships to define the hierarchal sub-menu structure through a single query. The query is usual cached for fast execution. The SELECT query generates each row which are normally injected into JavaScript, DHTML, Flash or into a templated C.S.S. (C.S.S. mixed with PHP ).
- Similar is defining the structure via XML. Reading XML in (PHP 5) simpleXML, and then again using JavaScript, DHTML, Flash or templated C.S.S.
ServerStormictus=="✓"
-
Mar 6, 2007, 18:57 #7
- Join Date
- Dec 2002
- Location
- Ann Arbor, MI (USA)
- Posts
- 648
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
By a separate system I mean separate database tables that deal with the structure of a menu, as opposed to the structure of various types of content (folders and articles). It seems like this would be beneficial because then menu organization doesn't depend on the organization of content within the system, but maybe they are just the same thing? It's really a theory question, I'm not so concerned with how the menu structure is created but moreso with what it is created from.
Thanks
Cory
-
Mar 6, 2007, 19:12 #8
- Join Date
- Feb 2005
- Location
- Burlington, Canada
- Posts
- 2,699
- Mentioned
- 89 Post(s)
- Tagged
- 6 Thread(s)
Cory,
Then I would highly recommend to create new tables that explicitly map to your desired Menu hierarchy.
ServerStormictus=="✓"
Bookmarks