首页 > 解决方案 > Mediawiki template url to anchor in other page

问题描述

I have a template with the following:

[[{{{Target}}}|{{{Name}}}]]

If called with {{tmpl|Target=Hest|Name=X}} I get a nice link to X as expected, if I call with {{tmpl|Target=Hest#here|Name=X}} I get "[[Hest#here|X]]", ie the text and no link.

How do I make it work with anchor tagged parameters?

标签: mediawiki

解决方案


你的例子应该有效。

这是如何做到的:

  1. 创建一个名为Template:tmpl内容的页面:

    [[{{{Target}}}|{{{Name}}}]]
    
  2. 创建一个名为Fruits内容的页面:

    This page lists important fruits.
    
    == Favorites ==
    
    * Apple
    * Pear
    * Orange
    
  3. 编辑另一个页面并添加:

    {{tmpl|Target=Fruits|Name=Link to page}}
    
    {{tmpl|Target=Fruits#Favorites|Name=Link to page with anchor}}
    
  4. 现在应该有两个链接:
    链接到页面
    链接到带有锚的页面

经验证可以在全新的 MediaWiki 安装上工作。


推荐阅读