【问题标题】:Tree structured sidebar in mediawikimediawiki 中的树形结构侧边栏
【发布时间】:2013-10-31 05:59:07
【问题描述】:

我已经完成了我的 mediawiki 侧边栏,如下所示。

*product1
**Welcome
**Introduction
**User Guide

*product2
**Welcome
**Introduction
**User Guide

我已经使用矢量扩展完成了这个,但我的要求是有一个像这样的 3 模型层次结构

*Product1
**Welcome
    ***Welcome1
    ***Welcome2
    ***Welcome3
 **Introduction
    ***Introduction1
    ***Introduction2
    ***Introduction3
 **User guide
    ***User guide1
    ***User guide2
    ***User guide3

该产品将有 3 个子链接,如 Welcome、introduction、UserGuide 、 Welcome 会有 Welcome1,WElcome2,welcome ,我想把它作为侧边栏中的第三层

【问题讨论】:

    标签: php mediawiki wikipedia


    【解决方案1】:

    添加到LocalSettings.php:

    $wgHooks['SkinBuildSidebar'][] = "fnSidebarMultiLevel";
    function fnSidebarMultiLevel(Skin $skin, &$bar) {
    
      global $wgOut;
    
      $sPanel = "* Product1
    ** Welcome
    *** Welcome1
    *** Welcome2
    *** Welcome3";
    
      $bar = array("Nav" => $wgOut->parse($sPanel)) + $bar;
    
    }
    

    适用于 1.14 及更高版本。

    【讨论】:

    • 感谢hack,但它有一些问题: 1. 如果以相反的顺序连接:$bar + array("Nav" => $wgOut->parse($sPanel)) 出现“导航”标题; 2. 文本对未认证用户也可见; 3. 文字样式很糟糕。
    • @Paul 1. 怎么了? 2. 符合预期 3. 与问题无关。
    • and what's wrong?: 1. 原序和逆序的行为不同。不知道如何在第一种情况下显示“导航”标题并在第二种情况下隐藏它; 2. 如果我想用西里尔字母显示“Nav”以外的其他标题,我不知道该怎么做。 3. 我希望不仅显示文本,而且使其易于理解、美观和实用(即,如果有视觉上可折叠/可折叠的关卡,折叠/展开应该真的有效)。看来我得用一些插件了。
    • @Paul 1. 你可以用 css 或 js 隐藏它 2. 你需要将 LocalSettings.php 保存在 UTF-8 中,没有 BOM。
    【解决方案2】:

    不可能有现成的第三级。为此,您需要使用自定义皮肤或创建扩展。

    如果你知道一些 PHP,你可以尝试使用 SkinBuildSidebar 钩子来呈现你想要的侧边栏。

    【讨论】:

    • 我也遇到了同样的问题,我在想,我可以在页面内有三层的树结构吗?我不想要目录,是否有任何扩展可以做到这一点?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-24
    • 1970-01-01
    • 1970-01-01
    • 2017-05-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多