有没有办法获得通过模板包含到 MediaWiki 页面上?

发布于 2024-12-28 06:56:24 字数 915 浏览 3 评论 0原文

我想将操作点添加到通过模板页面。这要求带有操作点的页面包含以下代码:

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

没企图 2025-01-04 06:56:24

这是一个可怕的黑客行为,但它确实有效。您将需要支持 safesubst: 的最新版本 MediaWiki。

  1. 创建包含内容 的页面 Template:Startinclude
  2. 创建包含内容 的页面 Template:Endinclude
  3. 使用以下内容创建页面 Template:Ap

<前><代码>头
<仅包含>{{safesubst:Startinclude}}
身体
<仅包含>{{safesubst:Endinclude}}

现在 {{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:.

  1. Create the page Template:Startinclude with the content <onlyinclude><onlyinclude></onlyinclude>.
  2. Create the page Template:Endinclude with the content </onlyinclude>.
  3. Create the page Template:Ap with this content:
Head
<includeonly>{{safesubst:Startinclude}}</includeonly>
Body
<includeonly>{{safesubst:Endinclude}}</includeonly>
Foot

And now {{subst:Ap}} expands to this:

Head
<onlyinclude>
Body
</onlyinclude>
Foot

For a live demo, enter {{subst:User:Jpatokal/Ap}} on any Wikipedia page, it uses this template.

吹泡泡o 2025-01-04 06:56:24

<onlyinclude> 的工作效果是否与 include>

Wouldn't <onlyinclude> and </onlyinclude> work just as well as <onlyinclude><onlyinclude></onlyinclude> and </only<noinclude></noinclude>include>?

囍孤女 2025-01-04 06:56:24

您可以在模板中应用以下技巧,以便嵌入和替换

<{{{fwd|onlyinclude}}}>Some text...</{{{fwd|onlyinclude}}}>
Some text...
<{{{fwd|noinclude}}}>Some text...</{{{fwd|noinclude}}}>

替换后 {{{ fwd|}}} 变量将在其位置扩展为默认值,您将获得所需的标签。我使用fwd作为forward的快捷方式,但您可以选择不同的名称。

以下是如何使用此方法通过模板替换将类别插入到页面中 - 模板内容应为:

<{{{fwd|noinclude}}}><includeonly>[[Category:CatName|?]]</includeonly></{{{fwd|noinclude}}}>

You could apply the following trick, within the template in order to transclude and substitute <onlyinclude> or <noinclude>:

<{{{fwd|onlyinclude}}}>Some text...</{{{fwd|onlyinclude}}}>
Some text...
<{{{fwd|noinclude}}}>Some text...</{{{fwd|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:

<{{{fwd|noinclude}}}><includeonly>[[Category:CatName|?]]</includeonly></{{{fwd|noinclude}}}>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文