【问题标题】:Drupal Site Map ModuleDrupal 站点地图模块
【发布时间】:2009-04-15 11:09:31
【问题描述】:

我正在寻找一个可以在 Drupal 中创建站点地图的模块,但找不到。我试过Site Map模块,但它只能生成一个站点地图页面;它不能在每个页面的末尾创建站点地图块。我也试过site menu module,但它也无法创建如上所示的站点地图块。

可能是我不知道怎么配置,但是我把每一个readme文件都看了,试了几天,还是不行。

有人知道吗?

【问题讨论】:

    标签: drupal


    【解决方案1】:

    我遇到了同样的问题,在尝试了一个模块(站点地图)但缺少自定义选项后,我编写了一个自定义模块。花了更少的时间弄乱站点地图模块,只需获取站点地图,以下代码就足够了(调整您的菜单):

    function sitemap_render_menu ($menu) {
        $output = "<ul>";
        foreach ($menu as $item) {
        $link = $item["link"];
        if ($link["hidden"]) {
            continue;
        }
    
        $output .= "<li><a href=\"" . check_url(url($link["href"], $link["options"])) . "\">" . $link["title"] . "</a></li>";
    
        if ($item["below"]) {
            $output .= sitemap_render_menu($item["below"]);
        }
        }
    
        $output .= "</ul>";
        return $output;
    }
    
    function sitemap_content () {
        $output = "<h1>Sitemap</h1>";
        $output .= "<span id=\"sitemap\">";
        $output .= sitemap_render_menu(menu_tree_all_data("your-menu"));
        $output .= "</span>";
        return $output;
    }
    
    
    function sitemap_menu () {
        $items = array();
    
        $items["sitemap"] = array (
            "title" => "Sitemap",
            "page callback" => "sitemap_content",
            "access arguments" => array("access content"),
            "type" => MENU_CALLBACK);
    
        return $items;
    }
    

    【讨论】:

      【解决方案2】:

      在http://groups.drupal.org/node/15980有站点地图模块的基本比较

      我使用了 sitemenu,它可以满足我的需求,但真正的答案取决于您如何使用分类法、内容类型等来构建您的网站。

      【讨论】:

        【解决方案3】:

        Auto Menu 之类的东西在这里也可能对你有用。您可以简单地将它生成的菜单添加到首页的页脚块中。

        【讨论】:

        • 不幸的是,自动菜单不适用于 Drupal 6 :(
        【解决方案4】:

        安装站点地图模块后,此 php 代码将打印站点地图。

        <?php echo theme('site_map'); ?>
        

        您可以创建一个空视图块并为空文本指定上述内容,选择 PHP 代码输入格式。

        可能有更好的方法来创建自定义块来显示php代码,但我不知道。

        【讨论】:

          【解决方案5】:

          我的想法是使用 Views 模块和自定义块类型。

          【讨论】:

            【解决方案6】:

            我认为您可以从Menu block 模块中受益。因为您可以在页脚中为您需要的所有菜单创建菜单块。然后,您可以将它们全部添加到页脚或使用 minipanels 块(来自panels 模块)的一个块中。

            【讨论】:

              【解决方案7】:

              您可以使用为我们提供可配置块的 Footer_sitemap 模块。 https://drupal.org/project/footer_sitemap

              【讨论】:

                【解决方案8】:

                这是一个最佳答案的小模型,它使用当前主题来显示层次结构

                function sitemap_render_menu ($menu) {
                
                    $output = "<ul  class='menu'>";
                
                    foreach ($menu as $item) {
                        $link = $item["link"];
                        if ($link["hidden"]) {
                            continue;
                        }
                
                        $cc=($item["below"]) ? "class='collapsed'" : '';
                
                        $output .= "<li $cc><a href=\"" . check_url(url($link["href"], $link["options"])) . "\">" . $link["title"] . "</a>";
                
                        if ($item["below"]) {
                            $output .= sitemap_render_menu($item["below"]);
                        }
                
                        $output .= "</li>";
                
                    }
                
                    $output .= "</ul>";
                    return $output;
                }
                
                function sitemap_content ($title,$menu) {
                    $output = "<h1>$title</h1>";
                    $output .= "<span id=\"sitemap\">";
                    $output .= sitemap_render_menu(menu_tree_all_data($menu));
                    $output .= "</span>";
                    return $output;
                }
                
                
                function sitemap_menu () {
                    $items = array();
                
                    $items["sitemap"] = array (
                      "title" => "Sitemap",
                      "page callback" => "sitemap_content",
                      "access arguments" => array("access content"),
                      "type" => MENU_CALLBACK);
                
                    return $items;
                }
                
                print sitemap_content("Navigational menu","Navigation");
                

                【讨论】:

                  【解决方案9】:

                  一个不依赖于作为菜单项包含的内容的简单解决方案可以通过以下方式实现:

                  创建一个新视图

                  作为一个块输出

                  使用字段:

                  内容标题(配置为“将此字段链接到原始内容”

                  内容类型(配置为“从显示中排除”)

                  格式为

                  带设置的无格式列表 - 分组字段 Nr.1 选择 Content:Type;

                  过滤条件: 内容:已发布(是) 内容类型 - 配置以选择您希望包含的内容类型;

                  排序标准 - 根据您的喜好配置

                  【讨论】:

                    猜你喜欢
                    • 1970-01-01
                    • 1970-01-01
                    • 2011-07-03
                    • 1970-01-01
                    • 1970-01-01
                    • 1970-01-01
                    • 1970-01-01
                    • 1970-01-01
                    • 1970-01-01
                    相关资源
                    最近更新 更多