`

将taxonomy输出为菜单

 
阅读更多
<?php
            // The ID of the taxonomy vocabulary for which you'd like to create a nested list
            $vid = 10;
            $depth = 0;
            $num_at_depth = 0;
            $tree = taxonomy_get_tree($vid);
            print "<ul class="menu">\n<li>";
            foreach ($tree as $term) {
            $diffdepth=0;
              if ($term->depth > $depth) {
                print "\n<ul>\n<li>";
                $depth = $term->depth;
                    $num_at_depth = 0;
              }
              if ($term->depth < $depth) {
                $diffdepth= $depth -$term->depth;
                while ($diffdepth > 0){
                    print "</li>\n</ul>\n";
                    $diffdepth -- ;
                }
                    $depth = $term->depth;
              }
              if (($term->depth == $depth) && ($num_at_depth > 0)) {
                  print "</li>\n<li>";
                }
              print l($term->name, 'taxonomy/term/' . $term->tid);
                $num_at_depth ++;
            }
            print "</li>\n</ul>\n";
?>

 

分享到:
评论

相关推荐

    Drupal views模块教程

    创建视图时,你需要指定视图名称(用于 URL 路径)、标题、描述以及输出类型(页面、区块或菜单)。 视图的输出类型: - 页面:创建一个新的网页,可覆盖原有页面。 - 区块:生成可在网站任何位置放置的区块,如侧...

    drupal专业开发指南(中文版).pdf

    - **文本格式化**: 将原始文本转换为适合显示的形式。 - **过滤器**: 应用安全策略,防止恶意代码注入。 - **用户自定义**: 允许用户选择喜欢的文本格式。 #### 十二、搜索和索引内容 - **全文搜索**: 快速检索网站...

    Drupal6开发手册

    Drupal 6 开发手册是为开发者提供的一份详尽指南,涵盖了Drupal 6框架的核心功能和扩展机制。这本书深入解析了Drupal的各个关键组件,帮助开发者理解和构建Drupal站点。 1. **第一章 Drupal的工作原理** - Drupal...

    drupal views

    Drupal Views 是 Drupal 内容管理框架中的一个核心模块,它为 Drupal 网站提供了强大的数据展示和查询功能。在 Drupal 中,Views 可以帮助用户以各种方式展示内容,如列表、网格、日历、地图等,无需深入编写代码。...

    WordPress框架结构分析 DOC

    - **模板渲染**:最后,WordPress将数据填充到模板中,生成HTML输出并返回给浏览器。 3. **开发工具** - **ZendStudio 7.2.1**:这是一个强大的PHP集成开发环境,用于编写、调试和优化WordPress代码。 - **...

Global site tag (gtag.js) - Google Analytics