将mediawiki TOC移至侧边栏 [英] Move mediawiki TOC to sidebar

查看:160
本文介绍了将mediawiki TOC移至侧边栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图找到一种方法,将MediaWiki中的TOC移动到侧边栏或任何真正需要它在主要内容之外的位置,但没有成功。



最简单的解决方案提出了以下内容,但似乎并没有实际移动TOC。

 < div id =toc_sidebar_holder> < / DIV> 

< script type =text / javascript>
var toc = document.getElementById('toc');
var toc_holder = document.getElementById('toc_sidebar_holder');
if(toc& toc_holder){
toc.parentNode.removeChild(toc);
toc_holder.appendChild(toc);
}
< / script>

然后,这里是目前TOC的HTML样式。

 < table id =tocclass =toc>< tr>< td>< div id =toctitle><<< tr ; H2>内容< / H2>< / DIV> 
< ul>
< li class =toclevel-1 tocsection-1>< a href =#Cats>< span class =tocnumber> 1< / span> < span class =toctext>猫< / span>< / a>
< ul>
< li class =toclevel-2 tocsection-2>< a href =#Type>< span class =tocnumber> 1.1< / span> < span class =toctext>类型< / span>< / a>< / li>
< li class =toclevel-2 tocsection-3>< a href =#Meows>< span class =tocnumber> 1.2< / span> < span class =toctext> Meows< / span>< / a>< / li>
< / ul>
< / li>
< li class =toclevel-1 tocsection-4>< a href =#Dogs>< span class =tocnumber> 2< / span> < span class =toctext>狗< / span>< / a>
< ul>
< li class =toclevel-2 tocsection-5>< a href =#Woof>< span class =tocnumber> 2.1< / span> < span class =toctext> Woof< / span>< / a>< / li>
< / ul>
< / li>
< / ul>
< / td>< / tr>< / table>

真的在寻找一个解决方案,或者找出如何让上面的函数起作用。

解决方案

该脚本看起来很好,但如果您测试它,您可能会注意到 toc 未分配。

将脚本放在皮肤的底部,以便在两个元素都可用时执行。

I've been trying to find a method on moving the TOC in MediaWiki to the sidebar or any location really that I want it outside of the main content but with no success.

The simplest looking solution brought up the following but it doesn't seem to actually move the TOC.

<div id="toc_sidebar_holder"> </div>

<script type="text/javascript">
    var toc = document.getElementById('toc');
    var toc_holder = document.getElementById('toc_sidebar_holder');
    if(toc && toc_holder){
        toc.parentNode.removeChild(toc);
        toc_holder.appendChild(toc);
        }
</script>

Then here is what the HTML looks like for the TOC currently.

<table id="toc" class="toc"><tr><td><div id="toctitle"><h2>Contents</h2></div>
    <ul>
      <li class="toclevel-1 tocsection-1"><a href="#Cats"><span class="tocnumber">1</span> <span class="toctext">Cats</span></a>
        <ul>
          <li class="toclevel-2 tocsection-2"><a href="#Type"><span class="tocnumber">1.1</span> <span class="toctext">Type</span></a></li>
          <li class="toclevel-2 tocsection-3"><a href="#Meows"><span class="tocnumber">1.2</span> <span class="toctext">Meows</span></a></li>
        </ul>
      </li>
      <li class="toclevel-1 tocsection-4"><a href="#Dogs"><span class="tocnumber">2</span> <span class="toctext">Dogs</span></a>
        <ul>
        <li class="toclevel-2 tocsection-5"><a href="#Woof"><span class="tocnumber">2.1</span> <span class="toctext">Woof</span></a></li>
        </ul>
      </li>
    </ul>
</td></tr></table>

Really looking for a solution or figuring out how to get the function above to work.

解决方案

That script looks fine, but if you you test it, you might notice that toc is not assigned.

Put the script at the bottom of your skin, so it is executed when both elements are already available.

这篇关于将mediawiki TOC移至侧边栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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