: How to have sidebar links to other wikis with similar articles? Sometimes Wikipedia or some other non-Wikimedia Foundation wiki will have an article with the same page title, about the same subject
Sometimes Wikipedia or some other non-Wikimedia Foundation wiki will have an article with the same page title, about the same subject but from a different perspective.
Like Wikipedia does for articles in other language versions. How to have links appear at the bottom of the sidebar when another wiki (from a selection) has an article with the same title?
e.g. An article on the local wiki called Ethernet will then have links to Wikipedia and Altera Wiki, while an article called Prototype X-37 doesn't because there is no such page on those wikis.
More posts by @Courtney195
1 Comments
Sorted by latest first Latest Oldest Best
To use the functionality built into Wikipedia you would have to have all of the Wikis belong to the same Wiki family.
Since your local Wiki is unlikely to be part of the Wikipedia family you could instead solve this with JavaScript, CSS and templates.
As an example creating a sidebar link to Wikipedia would require:
Create a template (e.g. Template:iwWikipedia) with:
<div class="interProject wikipedia" style="display:none;">[//en.wikipedia.org/wiki/{{{1|{{PAGENAMEE}}}}} Wikipedia]</div>
Add the following to your MediaWiki:Common.css
ul.interProject {
list-style: none;
padding-left: 0;
margin-left: 0;
}
li.interProject,
/* for Vector skin since the above doesn't take for some reason */ #mw -panel div.portal div.body ul.interProject li.interProject {
background-repeat: no-repeat;
background-position: left center;
padding-left: 18px;
margin-left: 0;
}
li.wikipedia {
background-image: url("//upload.wikimedia.org/wikipedia/commons/thumb/6/63/Wikipedia-logo.png/14px-Wikipedia-logo.png");
}
Add the following to your MediaWiki:Common.js
/**
* Adds interwikilinks to other projects in the left sidebar.
*/
$( function() {
var iwlinks = jQuery( 'div.interProject' );
if ( iwlinks.length > 0 ) {
var pproject = jQuery( '#p-tb' ).clone().attr( 'id', 'p-project' ).insertAfter( '#p-tb' );
pproject.find( 'h3' ).attr( 'id', 'p-project-label' ).text( 'On other projects' );
pproject.find( 'ul' ).addClass( 'interProject' ).empty().append( iwlinks );
iwlinks.replaceWith( function() {
return $( '<li></li>' ).addClass( $(this).attr( 'class' ) ).append( $(this).contents() );
});
}
});
Now adding {{iwWikipedia}} anywhere in your Ethernet article will add a link to the Ethernet article on English Wikipedia. If the articles don't have the same name simply add the desired name as an extra parameter e.g. {{iwWikipedia|Hello_World}} (with spaces replaced by underscores).
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.