SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: Menu design?

  1. #1
    Spirit Coder allspiritseve's Avatar
    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

  2. #2
    Foozle Reducer ServerStorm's Avatar
    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,
    ServerStorm
    ictus==""

  3. #3
    Spirit Coder allspiritseve's Avatar
    Join Date
    Dec 2002
    Location
    Ann Arbor, MI (USA)
    Posts
    648
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I appreciate the link, but I already have a system set up to store hierarchical data in my database. I am wondering whether a menu should be created from this data or in a separate system, merely linking to the data through ids.

    Quote Originally Posted by ServerStorm View Post
    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,
    ServerStorm

  4. #4
    Foozle Reducer ServerStorm's Avatar
    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.

    ServerStorm
    ictus==""

  5. #5
    Spirit Coder allspiritseve's Avatar
    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?

  6. #6
    Foozle Reducer ServerStorm's Avatar
    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?
    It makes sense if your existing hierarchy is structured in a way that you and expand or decrease the sub-menu layering as your site's needs grow. If your current hierarchy is not well set-up for this then you may consider to create a new database hierarchy that when joined together can provide a flexible yet dynamic menu system.

    I am not sure what you mean by
    a separate system?
    Could you elaborate on what your thoughts are about the benefit of a separate system and what the separate system might be?

    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.
    Regards,
    ServerStorm
    ictus==""

  7. #7
    Spirit Coder allspiritseve's Avatar
    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

  8. #8
    Foozle Reducer ServerStorm's Avatar
    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.

    ServerStorm
    ictus==""


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •