Help:Interwiki Transclusion

From About PCs Wiki
Jump to navigation Jump to search

Scary transclusion not working?[edit | hide | hide all]

It would be a good thing to use templates from a remote wiki. Miraheze provides actually a special wiki for this purpuse. The prefix for this wiki is templatewiki.

You have to enable scary transclusion (tab ⧼settings-edit⧽) if you want to use interwiki templates. When you check out this feature you will get some surprises.

Pure transclusion[edit | hide]

A glance into the manual helps.

{{wiki:template name}} or {{wiki:main namespace page name}} will transclude the remote wiki page content, not the wikicode of templates, etc. Actually you will get exactly the content that you see on your screen when you visit the template in the remote wiki. The template will not function because the pure HTML-Code is included in your wiki page. All links will point to the remote wiki.

{{templatewiki:Userlist}} transcludes as (anything inside the dotted borders)}}

[Template fetch failed for HTTP 404]
This behaviour is probably not what you expect and need.

Raw transclusion[edit | hide]

This is the solution for your problem. Use {{raw:templatewiki:Userlist}} to get the wanted result.}}

[Template fetch failed for HTTP 404]

The drawback of this method is that all included templates must be defined locally. Therefore I recommond following approach:

  • if you want to transclude template template sample define a template with the same name in the local wiki
  • insert following text into your template: <includeonly><onlyinclude>{{raw:templatewiki:template sample}}</onlyinclude></includeonly>
  • define all used subtemplates in the same way

Transclusion of a page outside the template namespace[edit | hide]

Information on the manual how to transclude pages outside the template namespace is misleading or even wrong.

Correct syntax: {{interwiki-prefix::{{FULLPAGENAME}}}}

Example: {{raw:templatewiki::User:Lily/sandbox}}

results in

This is a test.

Transclusion from main namespace: {{raw:yazz::Transclusion}} results in

linear-gradient(to right, red, #f80, #ff0, #8f0, #0f0, #0f8, #0ff, #08f, #00f, #80f, #f0f, #f08)

Template documentation[edit | hide]

If the template in the remote wiki contains template documentation, you can include this documentaton with {{templatewiki:template sample}} The content of your template would look like this

<includeonly><onlyinclude>{{raw:templatewiki:template sample}}</onlyinclude></includeonly>
{{templatewiki:template sample}}

If you want to make this even better define a template eg {{Transdoc}} in your local wiki that looks like this

|1=This documentation is included from the template {{Tl|1=Transdoc}}}}
== Local description ==
=== Local Usage ===
<div style="column-count: 2">{{Special:WhatLinksHere/Template:{{PAGENAME}}}}</div>
=== Local code ===
<div style="background-color: #aaa; width: 90%; border-radius: 1em; box-shadow: 0.1em 0.1em 0.5em rgba(0,0,0,0.75); padding: 0.5em;"><div style="background-color: #fff; padding: 1em; border-radius: 0.5em; font-family: monospace; white-space: pre-wrap;">
=== Local Subpages ===
== Remote Description ==
|1=This template as well as the [[#Remote Description|documentation]] is transcluded from [[{{{pre|templatewiki}}}:{{FULLPAGENAME}}|{{{wiki|Miraheze Template Wiki}}}]].<br>
All links refer to [[{{{pre|templatewiki}}}:|{{{wiki|Miraheze Template Wiki}}}]]}}</div>
}}[[Category:Transcluded from {{{wiki|Miraheze Template Wiki}}}]]</onlyinclude></includeonly>

This template displays the raw content of the local template, a list of local subpages a list of pages which link to this template as well as the remote documentation which is displayed on the remote template page.

Links[edit | hide]