Template:InterProject/doc

From blackwiki
< Template:InterProject
Revision as of 17:32, 12 February 2014 by imported>Brackenheim (Created page with '{{Documentation subpage}} <!-- Categories go at the bottom of this page and interwikis go in Wikidata. --> This template is used to generate links to sister pro...')
Jump to navigation Jump to search

This template is used to generate links to sister projects similar to Interlanguage links. The template creates a box with the listed links above the display of interwiki links in the sidebar. It is not intended for use in the article namespace.

Usage

{{InterProject
|meta=
|metaglobal=
|commons=
|b=
|n=
|q=
|s=
|v=
|d=
|wikt=
|voy=
|species=
|incubator=
|mw=
}}

Parameters

For every parameter the page name must be entered separately. It should be noted that the localized name of the target wiki or the international name is used for the namespace (for example, user for the user-namespaces). A leading colon is not required.

For every sister project you can exactly specify one link. In sister projects with different languages (like Wikibooks), however, you can link to languages other than English: with {{Interprojekt|b=de:User:Example}} you link to the German-language Wikibooks.

Programming

JavaScript must be enabled to use this template. To apply this template to a different wiki, the following javascript code is needed (see also MediaWiki:Common.js for the current code):

/** Code for [[Template:InterProject]] */
mw.loader.using( [ 'mediawiki.util' ], function() { jQuery( document ).ready(function() {
    var iProject = document.getElementById("interProject");
    if(!iProject) return;
    var sistersibling = document.getElementById("p-lang");
    if(!sistersibling) sistersibling= document.getElementById("p-tb");
    if(!sistersibling) return;
    var sisterparent = sistersibling.parentNode;
    var sisterprojectnav = document.createElement("div");
    sisterprojectnav.id = "p-sisterprojects";
    sisterprojectnav.className = sistersibling.className
    sisterprojectnav.innerHTML = '<h5>'+document.getElementById("sisterProjects").firstChild.innerHTML+'</h5><div><ul></ul></div>';
    var sistersiblingsub = sistersibling.getElementsByTagName("div")[0];
    if(sistersiblingsub){
        sisterprojectnav.childNodes[1].className = sistersiblingsub.className;
    } else {
        sisterprojectnav.childNodes[1].className = "pBody";
    }
    var sisternext = document.getElementById("p-lang");
    if ( sisternext && sisternext.parentNode == sisterparent ){
        sisterparent.insertBefore( sisterprojectnav, sisternext );
    }else{
        sisterparent.appendChild(sisterprojectnav);
    }
    var sisterlinks = iProject.getElementsByTagName("a");
    for (var i = 0; i < sisterlinks.length; i++) {
        var sistername = sisterlinks[i].firstChild.nodeValue
        mw.util.addPortletLink('p-sisterprojects', sisterlinks[i].getAttribute("href") + '?uselang=' + mw.config.get( 'wgUserLanguage' ), sistername, "sister-"+ sistername, sistername);
    }
})});
/** End of code for Template:Interproject */