Template talk:Hidden

From Wikipedia, the free encyclopedia

Examples:

{{hidden|lorem ipsum|{{lorem ipsum}}}}

{{hidden|ta1=left|bg1=cyan|bg2=yellow|lorem ipsum|{{lorem ipsum}}}}

Contents

[edit] See also


[edit] Why doesn't this work?

{{hidden|Kennedys hut|{{Wikipedia:Featured picture candidates/Kennedys hut}}}}

-->

Please advise. :( pfctdayelise (translate?) 23:35, 1 April 2006 (UTC)

I don't know. However, if I understand what you're trying to do correctly, it can be made to work by using a numbered parameter, like this:
{{hidden|Kennedys hut|2={{Wikipedia:Featured picture candidates/Kennedys hut}}}}
yields
Help:Template says that a parameter cannot contain }} so in particular templates cannot be nested. But this is apparently not the whole story. Is the work-around good enough for your purposes? I'm not sure it works in all cases. -- Jitse Niesen (talk) 06:12, 27 April 2006 (UTC)
Man, so easy to fix, thankyou! It's pretty much exactly what I want to do. I'll test it out and see how it goes. Thanks! pfctdayelise (translate?) 07:25, 27 April 2006 (UTC)

[edit] Limitations

Note that this template, 'hidden begin', and the 'NavFrame' methodology in general do not work in all Wikipedia 'skins', for users with non-CSS browsers browsers and screen readers, or on mirrors and foreign language versions which have not copied the MediaWiki:Monobook.css classes. In all such cases the user sees the full output all the time with no 'show/hide' feature. --CBDunkerson 11:22, 27 April 2006 (UTC)

Oh, is that the problem? I will edit Cologne Blue to fix this. Ashibaka tock 22:51, 4 May 2006 (UTC)
I can't get it to work... Ashibaka tock 22:58, 4 May 2006 (UTC)
You need relevant js from MediaWiki:Monobook.js also. AzaToth 05:24, 5 May 2006 (UTC)
Okay, currently MediaWiki:Cologneblue.js isn't actually loaded anywhere, but I added it to User:Ashibaka/cologneblue.js. Ashibaka tock 14:59, 5 May 2006 (UTC)
I got it working on a custom skin by adding this line to Skin.php in method getHeadScripts under the $r= line that looks just like it and before the if statement:
$r .= "<script type=\"{$wgJsMimeType}\" src=\"/index.php?title=MediaWiki:DSS.js\"></script>\n";
DSS is the name of my skin and i inserted the jscript into MediaWiki:DSS.js. There is probably a more elegant way. Let me know if this doesn't work, i wrestled for a while and wasn't controlling variables so there may be some other edit i made somewhere else that enabled it. Oh, that just covers the js side of the template, the css i just appended to the end of my skin's copy of main.css. Thanks a lot Gro.ikiwaidem 22:55, 3 November 2006 (UTC)

[edit] Expand all for printable pages

Is there a way to expand all hidden text for printable pages, but hide them all for regular pages? -- Sy / (talk) 01:32, 10 May 2006 (UTC)

[edit] Bug

Every template that uses this one demonstrates not entirely correct behaviour. It shows "Hide" by default and when you click it nothing happens, but the button changes to "Show". When you click it the second time the hidden content finally shows up. Is there a way to fix it? This seems to be fairly recent change. Grue 11:34, 17 May 2006 (UTC)

This problem was caused by my edit which inserted optional CSS styles to it. The Javascript apparently depends on a particular style, so that it assumed from the extra characters that the content was currently visible. Clicking the show/hide button the first time thus cleared the extra characters. I've reverted my changes; sorry for the long delay, but I was without Internet access for a while. // [admin] Pathoschild (talk/map) 15:28, 23 May 2006 (UTC)

[edit] Practical interference on AfD pages

This template is not working correctly on AfD nominated pages and its intrusiveness literally affects the outcome. I have brought this up with the {{afd1}} group, but they appear not to have the bug. If this could be made to work universally on all mediawiki skins it would be great, but until then could there be a note somewhere that it doesn't work currently and to restrict usage to non-essential purposes. Thanks, Ansell 02:40, 2 June 2006 (UTC)

[edit] Default to show

Can I set this up so it will default to showing, and then people can hide the text? (Like the TOC box) --michael180 21:58, 17 June 2006 (UTC)
Anyone? --michael180 15:15, 24 August 2006 (UTC)

Sorry to see no-one's ridden to the rescue, Michael; I don't know whether or not this is possible, but in lieu of anyone else responding, something that might be worth trying is to visit some of the pages using this template to see if/when/how they achieve a default setting of show. If you find one, please list it here! Meanwhile, it'd be useful to know whether or not it's possible to set TOC contents to hidden...
Hope you find a result one way or another, David Kernow 19:00, 24 August 2006 (UTC)
Update: Take a look at {{Ukrainian topics}}, which was displayed as shown when I arrived at Subdivisions of Ukraine. It uses an HTML-based method to implement show/hide which looks as if it can meet your case. Best wishes, David 20:42, 24 August 2006 (UTC)
Ah, I found what affected this behavior. In the wikibits javascript there is a statement which says that boxes should be auto hidden if there is more then 1 of these boxes. This number can be changed, if you happen to have access to the javascript file (so if you run your own wiki, you can change this). There seems to be no way to change this on a case by case basis. The {{Ukrainian topics}} example was auto shown because it was by itself. However, go to a page where it was included with other show/hides (eg. the page Ukraine), the box will be automatically hidden along with the rest. I think we need a smart developer to let this show/hide thing be controlled on a case by case basis. I will ask at the Wikipedia:Village pump (technical) --michael180 23:30, 1 September 2006 (UTC)
Update: The following line added to User:USERNAME/monobook.js makes the boxes default to open, if there is less then 999 of them on that page. However, this only affects you, and does not control the boxes individually. --michael180 00:33, 2 September 2006 (UTC)
NavigationBarShowDefault = 999;
Thanks for the insights. "...a statement which says that boxes should be auto hidden if there is more then 1 of these boxes" seems somewhat arbitrary, but perhaps it's an emergent limitation of the system. The "999" setting seems like a workaround... Yours, David 03:07, 2 September 2006 (UTC)
Check Wikipedia:Village_pump_(technical)#Template:Hidden_-_Auto_Show.2FHide, User:CesarB came up with a fix and he will change the wiki js in a few days. Way to go, User:CesarB. --michael180 21:42, 2 September 2006 (UTC)
I managed to derive a workaround for the "default to show" issue. I set the NavFrame id to 'show' or 'hide' and have modified the javascript code to handle this just before the id is changed to "NavFrame" + indexNavigationBar.
My (modified) code for my own wiki (it ignores NavPic and uses left allowed arrows for expanding / contracting):
 /** Dynamic Navigation Bars (experimental) *************************************
  *
  *  Description: See http://en.wikipedia.org/wiki/Wikipedia:NavFrame
  */
 var strHide = '▼';
 var strShow = '►';
 
 function toggleNavigationBar(indexNavigationBar) {
   var NavToggle = document.getElementById('NavToggle' + indexNavigationBar);
   var NavFrame = document.getElementById('NavFrame' + indexNavigationBar);
   
   if (!NavFrame || !NavToggle) return false;
   
   for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
     if (NavChild.className == 'NavContent') {
       NavChild.style.display = (NavChild.style.display=='none') ? 'block' : 'none';
     }
   }
   NavToggle.firstChild.data = (NavToggle.firstChild.data==strShow) ? strHide : strShow;
 }
 
 function createNavigationBarToggleButton() {
   var indexNavigationBar = 0;
   for(var i=0; NavFrame = document.getElementsByTagName('div')[i]; i++) {
     if (NavFrame.className == 'NavFrame') {
       indexNavigationBar++;
       
       var NavToggle = document.createElement('a');
       NavToggle.className = 'NavToggle';
       NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
       NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
       var NavToggleText = document.createTextNode(strHide);
       NavToggle.appendChild(NavToggleText);
       
       // Find the NavHead and attach the toggle link
       for(var j=0; j < NavFrame.childNodes.length; j++) {
         if (NavFrame.childNodes[j].className == 'NavHead') {
           NavFrame.childNodes[j].appendChild(NavToggle);
         }
       }
       switch (NavFrame.getAttribute('id')) {
         case 'hide':
           NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
           toggleNavigationBar(indexNavigationBar);
           break;
         default:
           NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
       }
     }
   }
 }
 
 addLoadEvent(createNavigationBarToggleButton);
And my NavFrames look like this:
 <div class="NavFrame" id="show"> /* or id="hide" */
 <div class="NavHead">Header goes here</div>
 <div class="NavContent">
 Content goes here
 </div>
 </div>
--210.23.133.248 02:07, 10 January 2007 (UTC)

[edit] JavaScript

How was JavaScript added to a Wikipedia template? I looked at the source code, but couldn't find any JS code. I would love to create scripted templates like that! Please explain!

FLaRN2005 (talk) 17:17, 21 August 2006 (UTC)

JavaScript cannot be added to a template. The JS code for this template is in MediaWiki:Monobook.js, whose contents are added to every web page (if the Monobook skin is used). See Help:User style for some more explanations. -- Jitse Niesen (talk) 05:26, 22 August 2006 (UTC)

[edit] position of the show link

Is there a way to put the 'show' not all the way to the right? Currently, I have an image on the right. and the 'show' link is on top of the image. I want the show to somehow be printed to the left of the image.

[edit] Bug?

Did this template just stop working for everyone? Because none of them work for me on any browser whether I'm logged in or not. I noticed that MediaWiki:Monobook.js just got moved to MediaWiki:Common.js[1]. Does something there need to get fixed? Koweja 23:21, 21 November 2006 (UTC)

Nevermind, it's working now. Koweja 00:55, 22 November 2006 (UTC)

[edit] Accessibility fix

Can someone modify the template so it provides a direct link to the page? That way if the show button doesn't work (because the page doesn't load properly or the user doesn't have javascript enabled) they can still see the page? Koweja 02:02, 23 November 2006 (UTC)

[edit] Displaying "hide" when the content is hidden

Why does this template display hide when the content is hidden? This is only when I open the template page, after clicking "hide" it starts to behave normally. --Eleassar my talk 13:02, 18 January 2007 (UTC)

[edit] Style questions

The designer in me must ask: What is the purpose of this hide/show mechanism? What kind of content should be used for this? What problem does it solve and is it the best solution to that problem? hateless 20:10, 19 January 2007 (UTC)

[edit] Spoilers

Something with this functionality could be used for Wikipedia:Spoilers. --84.20.17.84 10:12, 22 January 2007 (UTC)