Template talk:Navbox generic/Archive 4

Latest comment: 17 years ago by CapitalR in topic Class nowraplinks
Archive 1Archive 2Archive 3Archive 4Archive 5

Use of this template on own MediaWiki site

Hi. I have my own Wiki system, using the MediaWiki software. Unfortunatelly this software doesn't come with any templates. I find this particular template very handy, and would like to use it on my Wiki as well. Though when I copy the source code, I get nothing but plain text. I think I miss some other templates used on this one.
Can someone please tell me what other templates I need to copy to my own Wiki, or if anyone has another idea of get this template working on my site, is someone willing to help me with that? Thanks very much in advance :-) -Jort227 16:03, 27 July 2007 (UTC)

I don't think that the problem is missing templates (They will show op with a red link, just like normal missing pages) but that the problem is in a wrong configuration setting . I have (I think) the same problem and that is in the http://www.mediawiki.org/wiki/manual:$wgUseTidy setting. I only haven't got it working yet so I don't know if this is the cure. I hope this helps Peter Schwegler 07:34, 29 July 2007 (UTC)
I'm not really sure if it has to do with those settings. I have just copied the source code from the template info a new page of my own Wiki. I made a picture of the outcome, and posted that on Imageshack: picture of the error. -Jort227 11:19, 29 July 2007 (UTC)
What version of mediaWiki are you using? Because that error looks like its not evaluating rowspan value right. Anyway you need in addition to this template are (all of which are optional)
I don't think you need tidy enabled since it's all valid ;-), but you'd have to the option to allow user type HTML. But, it seem you already done that. —Dispenser 12:21, 29 July 2007 (UTC)
Thanks Dispenser for the hints :D. Though one question: where can I find the commons.css and commons.js files? And where do I need to put them in my own Wiki? Do I need to upload them via FTP (if so, to what folder), or do I just need to add them to my own wiki on the pagenames you've just mentioned? Anyway, thanks for the help, hopefully it'll work :) -Jort227 12:42, 29 July 2007 (UTC)
Sorry I wrote down the wrong link, fixed now. Looking at the result again, it looks more like that mw:ParserFunctions aren't enabled or that the syntax for the parser functions are different on your install. —Dispenser 20:14, 29 July 2007 (UTC)
I have uploaded the common.css and the common.js files to my wiki (just kept them the same as on this Wiki) and the other pages, but it still doesn't really look good. When I view the source, it's still somewhat the same as on my example image. So I guess it's because of the parser functions... Do you know how I can fix that? How I can set those functions, so that they work properly? Because I really like this template :). Thank you -Jort227 20:24, 19 August 2007 (UTC)

Even more changes

  • Temporarily removing editprotected flag so I can possibly make one more change before submitting the changes again. --CapitalR 00:44, 14 August 2007 (UTC)
    • I've found other ways to get around these problems, so just forget about these changes. I'll leave the discussion below for reference, but do not implement them. In the near future I may have more edits to address some of the problems, but not at this time. --CapitalR 13:05, 17 August 2007 (UTC)

I've noticed a few more common problems with use of this template and have made changes to correct them. The change is to put each of the {{{list_n}}} calls onto its own line to prevent incorrect spacing / newline errors in some browsers. This has always been a problem with this template (i.e., it's not a new problem introduced by my last edits) and should be fixed by this edit.

The code should be completely replaced with the following:

<table class="navbox collapsible {{{state|autocollapse}}}" style="margin:auto; {{{style|}}}{{{bodystyle|}}}">
<tr><!--

---Titlebar---
--><th colspan="{{#if:{{{image|}}}|3|2}}" style="text-align:center;width:100%;{{{titlestyle|}}}"><!--
--><div style="float:left; width:6em; text-align:left;">{{#switch:{{{navbar|}}} |plain= |#default={{Tnavbar|{{{name<noinclude>|Navbox generic</noinclude>}}} |mini=1}}}}</div><span style="font-size:110%;">{{{title}}}</span></th>
</tr><!--

---Above (optional)---
-->{{#if:{{{above|}}} |<tr><td style="{{{abovestyle|}}}" colspan="{{#if:{{{image|}}}|3|2}}">
{{{above|}}}
</td></tr>}}<!--

---Groups---
-->{{#if:{{{list1|}}}|<tr>{{#if:{{{group1|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group1}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{oddstyle|}}}" colspan="{{#if:{{{group1|}}}|1|2}}">
{{{list1}}}
</td><!--

-->{{#if:{{{image|}}}|<td rowspan="{{#expr: {{#if:{{{list1|}}}|1|0}} +{{#if:{{{list2|}}}|1|0}} +{{#if:{{{list3|}}}|1|0}} +{{#if:{{{list4|}}}|1|0}} +{{#if:{{{list5|}}}|1|0}} +{{#if:{{{list6|}}}|1|0}} +{{#if:{{{list7|}}}|1|0}} +{{#if:{{{list8|}}}|1|0}} +{{#if:{{{list9|}}}|1|0}} +{{#if:{{{list10|}}}|1|0}} +{{#if:{{{list11|}}}|1|0}} +{{#if:{{{list12|}}}|1|0}} +{{#if:{{{list13|}}}|1|0}} +{{#if:{{{list14|}}}|1|0}} +{{#if:{{{list15|}}}|1|0}} +{{#if:{{{list16|}}}|1|0}} +{{#if:{{{list17|}}}|1|0}} +{{#if:{{{list18|}}}|1|0}} +{{#if:{{{list19|}}}|1|0}} +{{#if:{{{list20|}}}|1|0}}}}" <!--
-->style="vertical-align:middle;padding-left:7px; width:0%;{{{imagestyle|}}}">
{{{image}}}
</td>}}</tr>}}<!--

-->{{#if:{{{list2|}}}|<tr>{{#if:{{{group2|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group2}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{evenstyle|}}}" colspan="{{#if:{{{group2|}}}|1|2}}">
{{{list2}}}
</td></tr>}}<!--

-->{{#if:{{{list3|}}}|<tr>{{#if:{{{group3|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group3}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{oddstyle|}}}" colspan="{{#if:{{{group3|}}}|1|2}}">
{{{list3}}}
</td></tr>}}<!--

-->{{#if:{{{list4|}}}|<tr>{{#if:{{{group4|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group4}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{evenstyle|}}}" colspan="{{#if:{{{group4|}}}|1|2}}">
{{{list4}}}
</td></tr>}}<!--

-->{{#if:{{{list5|}}}|<tr>{{#if:{{{group5|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group5}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{oddstyle|}}}" colspan="{{#if:{{{group5|}}}|1|2}}">
{{{list5}}}
</td></tr>}}<!--

-->{{#if:{{{list6|}}}|<tr>{{#if:{{{group6|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group6}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{evenstyle|}}}" colspan="{{#if:{{{group6|}}}|1|2}}">
{{{list6}}}
</td></tr>}}<!--

-->{{#if:{{{list7|}}}|<tr>{{#if:{{{group7|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group7}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{oddstyle|}}}" colspan="{{#if:{{{group7|}}}|1|2}}">
{{{list7}}}
</td></tr>}}<!--

-->{{#if:{{{list8|}}}|<tr>{{#if:{{{group8|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group8}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{evenstyle|}}}" colspan="{{#if:{{{group8|}}}|1|2}}">
{{{list8}}}
</td></tr>}}<!--

-->{{#if:{{{list9|}}}|<tr>{{#if:{{{group9|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group9}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{oddstyle|}}}" colspan="{{#if:{{{group9|}}}|1|2}}">
{{{list9}}}
</td></tr>}}<!--

-->{{#if:{{{list10|}}}|<tr>{{#if:{{{group10|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group10}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{evenstyle|}}}" colspan="{{#if:{{{group10|}}}|1|2}}">
{{{list10}}}
</td></tr>}}<!--

-->{{#if:{{{list11|}}}|<tr>{{#if:{{{group11|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group11}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{oddstyle|}}}" colspan="{{#if:{{{group11|}}}|1|2}}">
{{{list11}}}
</td></tr>}}<!--

-->{{#if:{{{list12|}}}|<tr>{{#if:{{{group12|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group12}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{evenstyle|}}}" colspan="{{#if:{{{group12|}}}|1|2}}">
{{{list12}}}
</td></tr>}}<!--

-->{{#if:{{{list13|}}}|<tr>{{#if:{{{group13|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group13}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{oddstyle|}}}" colspan="{{#if:{{{group13|}}}|1|2}}">
{{{list13}}}
</td></tr>}}<!--

-->{{#if:{{{list14|}}}|<tr>{{#if:{{{group14|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group14}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{evenstyle|}}}" colspan="{{#if:{{{group14|}}}|1|2}}">
{{{list14}}}
</td></tr>}}<!--

-->{{#if:{{{list15|}}}|<tr>{{#if:{{{group15|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group15}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{oddstyle|}}}" colspan="{{#if:{{{group15|}}}|1|2}}">
{{{list15}}}
</td></tr>}}<!--

-->{{#if:{{{list16|}}}|<tr>{{#if:{{{group16|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group16}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{evenstyle|}}}" colspan="{{#if:{{{group16|}}}|1|2}}">
{{{list16}}}
</td></tr>}}<!--

-->{{#if:{{{list17|}}}|<tr>{{#if:{{{group17|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group17}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{oddstyle|}}}" colspan="{{#if:{{{group17|}}}|1|2}}">
{{{list17}}}
</td></tr>}}<!--

-->{{#if:{{{list18|}}}|<tr>{{#if:{{{group18|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group18}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{evenstyle|}}}" colspan="{{#if:{{{group18|}}}|1|2}}">
{{{list18}}}
</td></tr>}}<!--

-->{{#if:{{{list19|}}}|<tr>{{#if:{{{group19|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group19}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{oddstyle|}}}" colspan="{{#if:{{{group19|}}}|1|2}}">
{{{list19}}}
</td></tr>}}<!--

-->{{#if:{{{list20|}}}|<tr>{{#if:{{{group20|}}}|<th style="white-space:nowrap;{{{groupstyle|}}}">{{{group20}}}</th>}}
<td style="width:100%;{{{liststyle|}}}{{{evenstyle|}}}" colspan="{{#if:{{{group20|}}}|1|2}}">
{{{list20}}}
</td></tr>}}<!--

---Below (optional)---
-->{{#if:{{{below|}}}|<tr><td style="{{{belowstyle|}}}" colspan="{{#if:{{{image|}}}|3|2}}">
{{{below|}}}
</td></tr>}}<!--

--></table><noinclude>{{{{FULLPAGENAME}}/doc}}
<!-- Add cats and interwikis to the /doc subpage, not here! -->
</noinclude>

Thanks, and once again this is implemented at User:CapitalR/Test with test cases visible at CapitalR/Test3. Also, click here for the diff. Note that the general style of the template is remaining the same; only spacing/new-line errors are being corrected. --CapitalR

Erm, that's not quite true; changing the title to nowrap will horribly break any use of this template where a narrow explicit width is used in conjunction with a long title. I don't particularly see the need for this change, in any case; where is the wrapping a problem? Kirill 17:12, 13 August 2007 (UTC)
  • Ok, well I just removed the nowrapping on the title, but I would still like to see the other change go through. The spacing problems being fixed by this change are illustrated as follows:
{{Navbox generic
|title = Title
|state=uncollapsed
|name=Navbox generic
|list1 = Item1 {{!}}
Item2 {{!}}
Item3 {{!}}
Item4
}}

Notice that the first and last items in the list are messed up (all should be on one line). Currently, the only way to fix this is as follows:

{{Navbox generic
|title = Title
|state=uncollapsed
|name=Navbox generic
|list1 = Item1 {{!}} <!--
-->Item2 {{!}} <!--
-->Item3 {{!}} <!--
-->Item4
}}

or

{{Navbox generic
|title = Title
|state=uncollapsed
|name=Navbox generic
|list1 = Item1 {{!}} Item2 {{!}} Item3 {{!}} Item4
}}


The new changes will do the following:

{{Navbox generic
|title = Title
|state=uncollapsed
|name=Navbox generic
|list1 = Item1 {{!}}
Item2 {{!}}
Item3 {{!}}
Item4
}}

{{USLargestCities}} {{USLargestMetros}}



{{USLargestCities}} {{USLargestMetros}}

Lots of editors like to put each item in a list on a newline to make the list easier to read (especially long lists with long wikilinks). Adding these extra line breaks to this master template will make it less confusing for editors who get those strange newline problems in child templates. I find it annoying to keep having to fix other editors mistakes by either removing the line breaks or adding the html comments around the line breaks in child templates, both of which make the child template code harder to read. This simple fix will improve working with this template and help avoid these errors for less experienced editors. I know that it will take up some server time to apply the changes, but it is well worth it. --CapitalR 18:18, 13 August 2007 (UTC)

Well, one solution (although not perfect) that I learnt from reading the docs for one of the other generic navboxes is to use a div tag. Like this:
{{Navbox generic
|title = Title
|state=uncollapsed
|name=Navbox generic
|list1 = <div>
Item1{{·}}
Item2{{·}}
Item3{{·}}
Item4
</div>
}}
Off course, it would be even better if the template took care of this so the editors don't need to think about div tags or similar.
--David Göthberg 19:40, 19 August 2007 (UTC)

Category field problem

Hey guys. I have been noticing that the category field in Template:Big 12 Football Venues, Template:SEC Baseball Venues, etc. (all the similar ones) are not including the category field for some odd reason for the Navbox generic. For instance, I was about to change the one for Template:Big 12 Basketball Venues to a Navbox generic so that it had the v/d/e controls and the division (North and South) could be separated like for Template:Big 12 Football Venues (among others), and I noticed that it was indeed working for that one. The reason the category is important is so it displays the category down at the bottom of all pages where it is (in this case the Big 12 Conference category). The noinclude ones still work, but not the regular category. Is this a fixable problem (am I doing something wrong?) or is just a flaw with the design of the Navbox generic? Any help is appreciated. (Cardsplayer4life 16:27, 16 August 2007 (UTC))

The problem would be that {{Navbox generic}} doesn't have a category parameter. This should be easy enough to fix, just request a change. --Dinoguy1000 Talk 03:56, 17 August 2007 (UTC)
Where would be the proper place to go about requesting such a change at? (Cardsplayer4life 05:28, 17 August 2007 (UTC))

In my opinion, the category parameters in nav boxes are a very bad idea. You can still do what you want without any changes to the template being necessary. All you need to do is add the following after the code for the Navbox generic and it will work:

<includeonly>[[Category:Big 12 Conference]]</includeonly> 

This has the effect of adding every page that uses the template to the category, but not the template itself. I modified {{Big 12 Football Venues}} as an example for you. Hope that solves your problems. --CapitalR 13:13, 17 August 2007 (UTC)

Thank you very much CapitalR. You are a gentleman and a scholar. (Cardsplayer4life 14:57, 17 August 2007 (UTC))

style="width:auto"

When the template is set to auto width the width shrinks significantly when the template is hidden. Can this behavior be changed so that the width stays the same whether the template is hidden or not? PaulC/T+ 14:37, 31 May 2007 (UTC)

Try "width: xem", where x is a number. But draw back of this is you need to know x in advance, and you need to give enough minimal white space so that there isn't excessive wraping. Another alternative is to not specify any width at all. --ChoChoPK (球球PK) (talk | contrib) 21:51, 31 May 2007 (UTC)
Neither of these suggestions fix the problem. The idea is to have a dynamically resized template that when collapsed is the same width as when it is expanded. There has been some discussion on other pages about the problem. Is this something that can be resolved or is the "width:auto" function essentially broken when the template is hidden? The only workaround I've seen is to hardcode the width of the template by ems or use "width:100%" to force the template to span the whole page. Am I missing something here? PaulC/T+ 23:12, 21 August 2007 (UTC)
Edit: More discussion below... PaulC/T+ 23:31, 21 August 2007 (UTC)
I've come up with a possible solution, but I don't know how to implement it. Essentially what there needs to be user-modifiable "minimum width" and "maximum width" parameters that the template could shrink and expand to without having to resort to width:auto;. Is this possible? I know you can specify an exact width, but this can look poor on screens with different resolutions... PaulC/T+ 08:53, 22 August 2007 (UTC)

{{editprotected}}

I have made a template and some CSS code that prevents word wraps inside links and only allows word wraps between the links and in normal text. This is useful for instance for long link lists.

The {{nowraplinks}} template has now been fully deployed and the CSS code added to common.css. I and other editors have tested it in several ways in several browsers. There for I suggest that the CSS class is used here (in Template:Navbox generic) to save users of this navigation box from using lots and lots of &nbsp; or {{nowrap}}. I have tested it with the template's current code in my own testpages/sandboxes.

I suggest that the first half of the first line should be changed to:

<table class="navbox collapsible {{{state|autocollapse}}} nowraplinks"

While I am at it I suggest that the last few lines be changed to:

--></table><noinclude>
{{pp-template|small=yes}}


{{template doc}}
<!-- Add categories and interwikis to the /doc subpage, not here! -->
</noinclude>

The change of the last few lines is to get the documentation look and feel recommended in Wikipedia:Template documentation. The two empty lines between the "pp-template" and the "template doc" is to prevent the documentation to come too close to the template, just to make the template page more readable.

--David Göthberg 20:13, 19 August 2007 (UTC)

  Done. See my note on Template talk:Navigation about spacing issues. Cheers. --MZMcBride 20:21, 19 August 2007 (UTC)

{{editprotected}}

Ehm, you misunderstood me. The primary change I suggest for the last lines is to add the {{template doc}}. Currently the more primitive {{/doc}} is used instead. The two blank lines were just layout extras. If/when the {{template doc}} is used the two blank lines can not be added in the /doc subpage since they will then end up inside the green {{template doc}} box.
--David Göthberg 21:03, 19 August 2007 (UTC)
My apologies.   Done. Cheers. --MZMcBride 21:10, 19 August 2007 (UTC)
All my fault for not being clear enough. Now the template page look very nice and I just did some additional testing and it seems the nowrap code works very nice out there in the real articles. --David Göthberg 21:16, 19 August 2007 (UTC)

Take a look at {{USLegislatures}} in IE and in Firefox. Both have problems associated with the nowraplinks modification to Navbox generic. In IE, it causes wrapping to occur before a right parenthesis and/or after a left parenthesis, which didn't happen before (and shouldn't happen). In Firefox, it causes the text to go outside of the box and off the screen, causing a scrollbar to appear sometimes. I like the nowraplinks addition, but perhaps we can find a way to correct this (I think I'll fix this template in particular with regular {{nowrap}} additions, but there are probably other templates out there with this problem too). --CapitalR 23:53, 21 August 2007 (UTC)

Yes, I was aware of both bugs. Firefox seems to calculate the width (of spaces I think) wrong when using nowraplinks. But in the tests I had done so far the text just went some pixels outside the box so I thought it was no big problem. But your example shows it can be much worse. And several of the browsers seem to sometimes allow line breaks immediately before and after a nowraps section even if according to rules they should not. But I have just seen it happen occasionally so I thought that that too was a to minor problem to bother about.
I am very interested to see if you can fix that template by using {{nowrap}} instead.
I have some other ideas too that might work around these bugs, but I need to test them carefully first. But those techniques will be tricky for the template users to grasp so they will probably use them wrong and cause nasty problems. I'll get back to you when I tested more.
--David Göthberg 01:26, 22 August 2007 (UTC)
I just updated that template using {{nowrap}}... could someone take a look and see if there is still a problem? (I'm using Safari on Mac OS X, so I can't check in IE.) Also, due to the nature of that template, I don't think the nowraplinks class will help at all with the wrapping since the sections that need to be kept together aren't in one single link... or am I looking too much into this? PaulC/T+ 01:33, 22 August 2007 (UTC)
Great work Psantora! Now that template looks fine in all my three browsers. (IE 5.5, Opera 9.02 and Firefox 2.0.) Nothing goes outside the box in my Firefox and line breaks only occur after the dots in all three browsers. Thanks Psantora. And you are right, in this case the nowraplinks class doesn't help much since we want to keep several links together here in sections.
But now the code in that navbox is as nasty as most such navboxes were before we had nowraplinks. So now that I had my lunch I'll go on and code up and test the solution I have in mind. Keep your fingers crossed that it works.
--David Göthberg 02:17, 22 August 2007 (UTC)
Ok, I have tested several solutions. Only the worst one of them worked. So I guess I need to think more about this. --David Göthberg 03:27, 22 August 2007 (UTC)
I managed to package my "worst solution" in a very nice way as ready to use templates. Take a look at {{nowrap begin}} and how I use it and its "helper templates" in {{USLegislatures}}. Now the code in {{USLegislatures}} looks good and is easy to maintain, and it works perfectly in all three web browsers I have. (IE 5.5, Opera 9.02 and Firefox 2.0.) I hope it works in Safari too. --David Göthberg 09:53, 22 August 2007 (UTC)
It looks good to me in all of the browsers that I have (same as you, but Safari also). When I was converting another 1000 templates to use {{Navbox}} last night, I noticed about 50 or so that had the same problem as the {{USLegislatures}} (I was using WP:AWB to make the conversions, which uses IE). The problems were all wrapping between parentheses and the words they surround. I think what I'll do is wait for the next database dump to come (in a week or two), and then run a simple scan to find all of the templates that have this problem and fix them manually. Thanks for looking into it for me. --CapitalR 13:35, 22 August 2007 (UTC)