Topic on Project:Support desk

[RESOLVED] Add Custom Tab or Tabs to Vector Skin

14
Oryulin (talkcontribs)

I would like to add custom tabs (NOT REMOVE) to a few specific pages. I would like to be able to have these tabs only on certain pages, which i think i could live without if there is no way to filter which page they show on, but I cant seem to find an answer as to how to actually add a custom tab.

I want the tab to be next to the "Discussion", "Read", or "Edit" tabs/buttons...just in that area, not some new set of tabs internal to the page as that looks horrible and is not the functionality i am looking for. Please assist me if you could...using 1.6.

Oh yes, also, I attempted asking in IRC with no luck...will try again in a day or two...hopefully this thread will provide some answers before then...

Oryulin (talkcontribs)
Krinkle (talkcontribs)

MediaWiki 1.6 is no longer supported. Please upgrade to 1.16.

Several methods (both server side / PHP and client side JavaScript) are available to add tabs.

In JavaScript the code would be (eg. in MediaWiki:Common.js):

var conf = mw.config.get([
    'wgCanonicalNamespace',
    'wgTitle',
    'wgPageName'
]);
// Only do the following on the Project:Sandbox page. 
if ( conf.wgCanonicalNamespace === 'Project' && conf.wgTitle == 'Sandbox' ) {
    // Add a link to the actions menu to Special:Log for this page.
    mw.loader.using( 'mediawiki.util', function () {
        mw.util.addPortletLink(
            'p-cactions',
            mw.util.getUrl( 'Special:Log', { page : conf.wgPageName } ),
            'Logs'
        );
    } ); 
}

If you save that to MediaWiki:Common.js and visit Project:Sandbox on your wiki (don't forget to clear cache), there will be a "Logs" link in the actions menu now.

addPortletLink works like addPortletLink( add where, link to, click text );

  • 'p-cactions' is the actions menu (Move etc.)
  • 'p-tb' is the toolbox in the sidebar (What links here, Permanent link, etc.)
Oryulin (talkcontribs)

Done, but still facing issues:

  • Version of MediaWiki is 1.16
  • MediaWiki:Common.js - contains the code you have above (if statements with addPortletLink code)
  • Cleared cache and used other browser to ensure, visited Project:Sandbox and there was not any Logs link/action menu...

Also was this code supposed to add a Tab or a Drop Down option? I don't see either one but i am trying to ensure i know where i am looking.

If i can get this code working i can tailor the rest, just need an idea of the original working code.

Krinkle (talkcontribs)
Oryulin (talkcontribs)

Yes I have the exact same thing in my MediaWiki:Common.js

I also added it to the same exact page you did for modern and switch to modern and still nothing, what could be conflicting causing it to not work?

Oryulin (talkcontribs)

Also tried taking out the "if" statement to see if it would add to all pages, and nothing as well.

Krinkle (talkcontribs)

Well, as you can see it works here so the problem isn't in the code.

Unless you link to the site or present an actual error message there isn't much we can do.

Oryulin (talkcontribs)

I thought there were several methods? Not to sound rude, but I would really appreciate getting one of them to work, there is no error messages/anything. I know the Mediawiki:Common.js works as I have it loading collapsible tables and it works fine for me there...so I haven't any idea since it doesn't throw any errors, just doesn't show a Logs tab.

Reach Out to the Truth (talkcontribs)

Until we know what's causing it to not work, we can't be sure that any other method can work either. There should be some sort of error. Are you using Firebug or a similar tool? That might be useful.

Oryulin (talkcontribs)

Well I guess its a lost cause, I installed firebug, enabled all, dove through what i could looking around, doesnt report any errors...clueless.

Oryulin (talkcontribs)

Alright i used a Ubuntu VM and installed fresh apache/php/mysql/mediawiki. Attempted this code for vector on the MediaWiki:Common.js and/or MediaWiki:Vector.js, took away the if statements to allow it on all pages and kept the if statement to attemp Project:Sandbox page only...nothing is working. The only changes to the default Localsettings.php that i have made on the fresh installation was authority to add myself as other groups like administrator/ect. Still not seeing the tab anywhere. Also tested on MediaWiki:Modern.js and MediaWiki:Monobook.js and switched to those themes, once with no if statement and only the addportlet line and the other with the if statement and checking the Project:Sandbox page...I am definately at a loss, is there an extension that i need to have this work? So if a fresh installation doesn't work and an older installation doesn't work, what is missing to make this work? Firebug reports 0 errors, i can see where it loads the Modern.js/Vector.js/Common.js/ect, but it points to a line in the code that looks to be the addportlet portion and its just not working/accepting it properly. Ideas? Other routes?

Oryulin (talkcontribs)
Oryulin (talkcontribs)

Alright, i dont know why the code above didnt work, but i messed around a bit and managed to make it work a slightly different way:

Content of my MediaWiki:Common.js file:

function createTab() {
 addPortletLink( 'p-cactions', wgArticlePath.replace( '$1', 'Special:Log' ), 'Logs');
}
addOnloadHook( createTab );
Reply to "[RESOLVED] Add Custom Tab or Tabs to Vector Skin"