Forum:Need history link that works in Wiki-navigation

Please see:
 * http://cannabis.wikia.com/wiki/Main_Page

See the "wiki tools" navigation menu at the top of the main page and click on "Page history" or "What links here." I have tried many things, and can't get them to work specifically for the page where the menu is found. I know there is some easy way to do this because these links are found in Monobook, Vector, Monaco, etc. skins. I want to add them to the "wiki tools" site menu at the top of every page. That menu is created here:
 * http://cannabis.wikia.com/wiki/MediaWiki:Wiki-navigation

Here are the types of links I am trying to end up with:
 * http://cannabis.wikia.com/index.php?title=Main_Page&action=history
 * http://cannabis.wikia.com/wiki/Special:WhatLinksHere/Main_Page

The best I could do was to get the history or "what links here" for MediaWiki:Wiki-navigation. But not the page where it is transcluded into. Here are some wikilinks and "magic words" I have tried:


 * recentchanges-url|recentchanges - recentchanges
 * Special:RecentChanges|Recent changes - Recent changes
 * Special:WhatLinksHere|What links here - What links here
 * whatlinkshere|whatlinkshere - whatlinkshere

Some with "magic words":


 * Special:WhatLinksHere/|What links here

Special:WhatLinksHere/|What links here

What links here


 * |History

|History


 * |History

|History


 * &action=history|Page history

&action=history |Page history


 * |Page history

|Page history
 * |What links here

|What links here

See: --Timeshifter 21:05, January 26, 2011 (UTC)
 * http://www.mediawiki.org/wiki/Help:Magic_words
 * http://meta.wikimedia.org/wiki/Help:Magic_words
 * http://meta.wikimedia.org/wiki/Help:Variable#Examples_of_combinations_with_parser_functions


 * You'll need JS. It may be easiest to omit those parts of the menu from MediaWiki:Wiki-navigation, and create them using pure JS.

/* add history and what links here to the menu */ function ToolsMenuItems { $('section header nav ul li:nth-last-child(2) ul li:first-child').after('HistoryWhat Links here'); } addOnloadHook(ToolsMenuItems); That will add history and what links here to the menu, assuming you have at least one thing in the menu already.


 * Can you show me where this is working? I am not clear how or where it ends up. --Timeshifter 21:13, January 26, 2011 (UTC)


 * Sure -  specifies the element (quite specifically, actually) that the content is going to be appended to.   just means "insert after".   is both of the menu items being added. They use a variable that is automatically declared on every page, "wgPageName", and isn't dependent upon the specific page it's written (  will always give the name of the page it is written on, even if displayed on another page).


 * Please update the comments part of the JS above. They seem very misleading to (although it appears to give me some credit). From what I can tell the JS adds a History and What Links Here link to whatever happens to be the 3rd wiki menu and strangely as the 2nd and 3rd items specifically. -- Fandyllic (talk &middot; contr) 1:49 PM PST 26 Jan 2011


 * Whoops. I stole the code from my global.js and changed it up, clearly I missed the comment line. It specifically attaches it to the second menu from the right (significant if you have more than 4 menus), and always as the second and third item in the drop down.


 * Thanks, works great! I added the JS here:
 * http://cannabis.wikia.com/wiki/MediaWiki:Wikia.js
 * Thanks also to both of you for the explanations. I am wondering about this info: "Page-dependent magic words will affect or return data about the current page (by default), even if the word is added through a transcluded template or included system message." It is from this page:
 * http://www.mediawiki.org/wiki/Help:Magic_words --Timeshifter 22:22, January 26, 2011 (UTC)

(unindent) That's pretty much the same as what I said above, only in much fancier terminology. will always give the name of the page it is written on, even if displayed on another page. Basically, if you use in a template, it will give you the name of the template, and when you put that template on other pages, it will still give you the name of the template. Think of MediaWiki:Wiki-navigation as a template in that sense.


 * I need to rewrite that sentence because it really confused me. So I guess those links on the toolboxes on various skins operate via JS code?


 * The links have disappeared from the wiki tools menu. I assume Wikia may be working on JS stuff trying to fix some of the problems that have come up with MediaWiki 1.16. --Timeshifter 23:01, January 26, 2011 (UTC)


 * Possibly something to that effect. JS seems to be going in and out of functionality periodically. And the automatic toolbox links aren't using JS - they're using MediaWiki software. You can add some with JS, but the basic ones come from MediaWiki. Actually, it's possible MediaWiki does it with JS, I guess.


 * Yes, it looks like JS is also not currently working for Show-Hide tables. All the tables are open on the Cannabis Wiki, and there are no show/hide links on the tables. See:
 * http://cannabis.wikia.com/wiki/Category:Collapsible_box_templates --Timeshifter 01:43, January 27, 2011 (UTC)


 * I think that may be my fault - what was the last JS I gave you?


 * Also take a look at Forum:Enabling Collapsible Tables and see if any info there helps. -- Fandyllic (talk &middot; contr) 5:48 PM PST 26 Jan 2011


 * The JS has been added and removed from here:
 * http://cannabis.wikia.com/wiki/MediaWiki:Common.js
 * http://cannabis.wikia.com/wiki/MediaWiki:Vector.js


 * Monchoman45. It looks like you are right. I removed all the JS for the skin buttons, and now the tables have show-hide buttons. Also, the history and "What links here" links are back in the wiki tools menu.


 * The last JS was the bit that put the skin links in the wiki tools menu. Previously, the JS that put the links elsewhere worked fine (except for the Vector buttons).


 * I tried adding back just the JS for the monobook tab links for skins. It worked previously, but it did not work this last time. Also, show-hide tables were messed up again in all skins by this attempt. Also, the added wiki tools menu links for history and "What links here" disappeared. So, I think something is messed up due to changes by Wikia today. --Timeshifter 03:59, January 27, 2011 (UTC)

(unindent) I was able to successfully break Common.js on my wiki in a similar way to the one you're describing. Try removing the history/what links here function and the oasis/monobook function, and adding in this, which combines them into one function: /* add history, what links here, and skin change buttons to the menu */ function ToolsMenuItems { $('section header nav ul li:nth-last-child(2) ul li:first-child').after('HistoryWhat Links here</a></li>'); $('section header nav ul li:nth-last-child(2) ul li:nth-last-child(1)').after('<a href="/index.php?title='+ encodeURIComponent(wgPageName) +'&useskin=monobook" title="Change to Monobook">Monobook</a></li><a href="/index.php?title='+ encodeURIComponent(wgPageName) +'&useskin=vector" title="Change to Vector">Vector</a></li>'); }

addOnloadHook(ToolsMenuItems); I tested it, and it should work.


 * It works great! Thanks. I like how the Oasis and Monobook links are separated by the "Edit this menu" link. I also put a link in the Wiki tools menu to this thread. --Timeshifter 20:34, January 27, 2011 (UTC)


 * "Edit this menu" doesn't show up for users who aren't Admins, so for them it'll look like it's after the last link.


 * OK, I did not know that. Thanks. To clarify things a little better for new readers I changed the names from Monobook to Monobook skin, and from Oasis to Oasis skin. --Timeshifter 21:54, January 27, 2011 (UTC)

(unindent). For those who are interested there was also discussion about the skin buttons/links here:
 * Forum: Vector skin and MediaWiki 1.16.

Helpful info about the top menus is consolidated here:
 * http://cannabis.wikia.com/wiki/Wiki_tools --Timeshifter 12:15, February 9, 2011 (UTC)