Predrag Stojadinović
Predrag Stojadinović

Reputation: 3659

MediaWiki variant tabs

Anyone knows how to get the variant tabs to work as actual tabs and not as a drop down?

This is how sr.wikipedia.org has it: desired solution, as seen on sr.wikipedia.org

and this is how I have it on my zablude.com/wiki/ page: enter image description here

and I've tried everything I found and searched everywhere I could think of but I wasn't able to find a solution... anyone has any ideas how this works?

Upvotes: 2

Views: 430

Answers (2)

Ilmari Karonen
Ilmari Karonen

Reputation: 50358

They hack it in JavaScript — see this piece of code at the bottom of Медијавики:Vector.js:

//to be able to switch the language variant (overrides the default buttons with more visible ones)
function tabWorkaround() {
    if(mw.config.get('wgUserVariant') == 'sr') {
        var tab_urls = {};
        tab_urls[0] = document.getElementById('ca-varlang-0').getElementsByTagName('a')[0].href; //Ћирилица
        tab_urls[1] = document.getElementById('ca-varlang-1').getElementsByTagName('a')[0].href; //Latinica
        $('#p-variants').remove();
        mw.util.addPortletLink('p-namespaces', tab_urls[0], 'Ћирилица');
        mw.util.addPortletLink('p-namespaces', tab_urls[1], 'Latinica');
    }
}
$(document).ready(tabWorkaround);

It would probably be cleaner to do it with a MediaWiki hook, though. The following code is untested, but should work if I haven't made any silly mistakes:

// show language variants as tabs in Vector skin
function tabWorkaround( &$skintemplate, &$links ) {
    $links['namespaces'] += $links['variants'];
    $links['variants'] = array();
    return true;
}
$wgHooks['SkinTemplateNavigation::Universal'][] = 'tabWorkaround';

(In MW 1.17, this hook is only called from the Vector skin. In MW 1.18, it will affect all skins. If you don't want that, you could test whether $skintemplate->skinname == 'vector'.)

Upvotes: 2

Tgr
Tgr

Reputation: 28200

Try $wgVectorFeatures['collapsibletabs']['global'] = false;. That is intended for the dropdown on the other side, but might work for other dropdowns as well.

Upvotes: 0

Related Questions