您如何生成网站导航? [英] How do you generate website navigation?

查看:70
本文介绍了您如何生成网站导航?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对其他人如何处理网站导航感兴趣.不是样式或可用性部分,而是生成部分.大多数网站都有某种导航树",以一个或多个菜单级别的形式显示–您以哪种形式保存和处理该树?最简单的解决方案是静态菜单模板,如下所示:

I am interested in how other people handle website navigation. Not the styling or usability part, but the generation part. Most websites have some kind of "navigation tree" that is displayed in form of one or more menu levels – in what form do you save and process this tree? The simplest solution is a static menu template, something like this:

<ul id="menu">
   <li><a href="…">One</a></li>
   <li><a href="…">Two</a></li>
   <li><a href="…">Three</a></li>
</ul>

但这不是很灵活.您不能简单地在菜单中标记当前页面,也没有简单的方法来显示或隐藏菜单树的一部分,具体取决于当前页面. (或者是吗?)

But this is not very flexible. You can’t simply mark the current page in the menu and there’s no simple way of showing or hiding a part of the menu tree depending on the current page. (Or is it?)

我想出了一个导航树,像这样:

I came up with a navigation tree, something like this:


    - title: Fruits
      nodes:
        - title: Apples
        - title: Oranges
        - title: Bananas
    - title: Music and Stuff
      url: music
      nodes:
        - title: Classical
        - title: Jazz

此树由特殊的Navigation类加载,该类可以根据当前请求路径为导航的一部分提供服务.这似乎更好一些,但是我仍然对其他人的解决方案感到好奇.

This tree gets loaded by a special Navigation class that can serve parts of the navigation depending on the current request path. This seems to work a bit better, but still I am very curious about other people’s solutions.

推荐答案

MySQL有一篇名为在MySQL中管理层次结构数据" ,我以前发现它非常有价值.它讨论了存储动态导航的两种常用技术及其局限性.

MySQL has an article entitled "Managing Hierarchical Data in MySQL" which I have previously found to be quite invaluable. It discusses two common techniques to storing dynamic navigation and their limitations.

这篇关于您如何生成网站导航?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆