有没有办法获得通过模板包含到 MediaWiki 页面上?
我想将操作点添加到通过模板页面。这要求带有操作点的页面包含以下代码:
<onlyinclude><includeonly>
</includeonly>#AP1 blah</onlyinclude> ... blah blah blah <onlyinclude><includeonly>
</includeonly>#AP2 blah</onlyinclude>... blah
但我希望通过模板实现此目的,以便用户只需添加类似以下内容:
{{subst:Action point|<action>}}
使用模板:{{Action point}}
。
问题是将 添加到页面。我可以添加
使用:
`<onlyinclude><onlyinclude></onlyinclude>`
我尝试使用
和
添加隐藏注释,但什么也没有似乎有效。
有什么想法吗?我正在寻找的解决方案是(如上面的链接所解释的)我可以在一个页面上添加带有操作点的文本(会议纪要),而在另一个视图上仅添加操作点。
I want to add action points to a page via a template. This requires that the page with the action points contains this code:
<onlyinclude><includeonly>
</includeonly>#AP1 blah</onlyinclude> ... blah blah blah <onlyinclude><includeonly>
</includeonly>#AP2 blah</onlyinclude>... blah
But I want this via a template, so that a user only has to add something like:
{{subst:Action point|<action>}}
using the template: {{Action point}}
.
The problem is adding the </onlyinclude>
to a page. I can add <onlyinclude>
using:
`<onlyinclude><onlyinclude></onlyinclude>`
I've tried adding hidden comments, using <noinclude>
and <includeonly>
but nothing seems to work.
Any ideas? The solution I'm looking for is where (as the above link explains) I can add text (meeting minutes) with action points on one page, and on another view only the action points.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个可怕的黑客行为,但它确实有效。您将需要支持
safesubst:
的最新版本 MediaWiki。
的页面Template:Startinclude
。的页面
Template:Endinclude
。Template:Ap
:现在
{{subst:Ap}}
扩展为:对于现场演示,请在任何维基百科页面上输入
{{subst:User:Jpatokal/Ap}}
,它使用 此模板。This is a monstrous hack, but it works. You will need a recent version of MediaWiki that supports
safesubst:
.Template:Startinclude
with the content<onlyinclude><onlyinclude></onlyinclude>
.Template:Endinclude
with the content</onlyinclude>
.Template:Ap
with this content:And now
{{subst:Ap}}
expands to this:For a live demo, enter
{{subst:User:Jpatokal/Ap}}
on any Wikipedia page, it uses this template.<onlyinclude>
和的工作效果是否与
和include>
?Wouldn't
<onlyinclude>
and</onlyinclude>
work just as well as<onlyinclude><onlyinclude></onlyinclude>
and</only<noinclude></noinclude>include>
?您可以在模板中应用以下技巧,以便嵌入和替换
或
:替换后
{{{ fwd|}}}
变量将在其位置扩展为默认值,您将获得所需的标签。我使用fwd作为forward的快捷方式,但您可以选择不同的名称。以下是如何使用此方法通过模板替换将类别插入到页面中 - 模板内容应为:
You could apply the following trick, within the template in order to transclude and substitute
<onlyinclude>
or<noinclude>
:After the substitution the
{{{fwd|}}}
variable will be expanded at its place with the default value and you will get the desired tags. I'm using fwd as shortcut of forward, but you could choice different name.Here is how to insert a category in to a page by template substitution using this approach - the template content should be: