Template talk:Navbar

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

Three templates, one function?[edit]

So after a related TFD I realized that this template, {{v}}, and {{view}} all pretty much do the same things. It would be fairly straightforward to add in the h/m/w links to the navbar module, so does it really make sense to have three templates? Primefac (talk) 19:33, 17 February 2017 (UTC)

Seems like a straight forward candidate for merging to me. SFB 21:03, 17 February 2017 (UTC)
Template:V was actually meant to replace Navbar. It was designed for more extensibility and intuitive utilization. Essentially anything can easily be done with V. 86.218.97.221 (talk) 04:03, 29 January 2018 (UTC)

Protected edit request on 13 May 2017[edit]

Could the contents of the sandbox be copied to the main template? This change fixes the formatting for the square brackets so that they render properly without HTML Tidy. Thanks, Jc86035 (talk) Use {{re|Jc86035}}
to reply to me
07:28, 13 May 2017 (UTC)

Done Primefac (talk) 12:41, 13 May 2017 (UTC)

Generalize the title text[edit]

Currently, the title text of each link specifies "template". However, {{Navbar}} is explicitly designed to be usable with non-template pages, and in these cases the word "template" may not be appropriate. Therefore, the text should be generalized, at the very least by taking the namespace of the page passed to {{Navbar}} into consideration, and possibly also with a parameter allowing customization. ディノ千?!? · ☎ Dinoguy1000 13:20, 5 September 2017 (UTC)

Dinoguy1000, please show me where this template is being used in a non-template manner. Primefac (talk) 14:45, 5 September 2017 (UTC)
I can't point to anywhere on Wikipedia off-hand; this is more a concern for reusers on other wikis (though personally I have little doubt there are uses even here that would benefit). While certainly individual wikis could modify the module to their liking, that would require them to be aware of the current behavior and to have an editor on-hand capable of working with Lua, and every wiki would have to redo the work for themselves (or find another wiki that had already done the requisite work).
While it is certainly true that template/module maintainers on Wikipedia have no obligation to consider reusers on other wikis, this is a relatively simple and minor adjustment that I believe would have some benefit here as well. ディノ千?!? · ☎ Dinoguy1000 22:27, 5 September 2017 (UTC)
Sorry to belabour this point, Dinoguy1000, but do you have evidence on other wikis that this is happening? Don't get me wrong, I understand your concerns, but there really is not much point in fixing something that isn't broken, as they say.
As a minor note, I do not see anywhere in the documentation (either on the template or the module) that it is explicitly designed to be usable with non-template pages; as far as any non-template-space usage is concerned, it's not prohibited but it's not exactly encouraged either. Primefac (talk) 12:15, 6 September 2017 (UTC)
While perhaps not the best example, the template is used in exactly the way I describe by the Yu-Gi-Oh! Wikia; see for example http://yugioh.wikia.com/wiki/Shonen_Jump_promotional_cards#List
Yes, I shouldn't have used the word "explicitly", really. I can't answer whether the past editors of this template/module ever made changes with the explicit purpose of supporting uses for non-template/module pages, but certainly it was originally designed solely for use with templates, and at some point was generalized (some time before the rename from Tnavbar in April 2009; it's worth noting that the move rationale does explicitly state that the rename is in response to the template being generalized to work with all namespaces). ディノ千?!? · ☎ Dinoguy1000 11:09, 10 September 2017 (UTC)
Been digging through the lua module, and when it all comes down to it, there's a simple way to check this sort of thing. I just did this, which produces <<subpage changed, permaLink is Special:PermaLink/799897098>>
which links to the proper location. So it does work in all namespaces. Primefac (talk) 13:35, 10 September 2017 (UTC)
I never said it doesn't, only that, when originally created, it didn't. It was generalized at some time between its creation in 2006 and the rename from Tnavbar to Navbar in 2009 so that it would work with any namespace. ディノ千?!? · ☎ Dinoguy1000 13:20, 13 September 2017 (UTC)
Okay, you've completely lost me. You asked that it work in all namespaces, but it does, and now you say that you know it does. What are you wanting? Primefac (talk) 13:44, 13 September 2017 (UTC)
The title text (the text that appears when you hover over one of the links - "View this template", "Discuss this template", "Edit this template") is specific to the Template namespace; it is this that I'm requesting be made to work with any namespace. I acknowledged in my original comment that the template overall already works with any namespace. ディノ千?!? · ☎ Dinoguy1000 14:09, 20 September 2017 (UTC)
Hover text. Gotcha.
Now I'm going to argue semantics with you, because one can have a user space template (such as User:Primefac/RS or User:UBX/AAHL-Loggers. Just because it isn't in the template namespace doesn't mean that a transcluded page isn't a "template". Primefac (talk) 15:28, 20 September 2017 (UTC)
This is Module:Navbar which contains the following three (non-contiguous) lines:
				:attr('title', 'View this template')
				:attr('title', 'Discuss this template')
					:attr('title', 'Edit this template')
I'm no Lua expert, so I don't know how those three instances of "template" might be conditionally altered to "page". --Redrose64 🌹 (talk) 19:35, 20 September 2017 (UTC)

─────────────────────────It could, but that would create all sorts of confusion. Here's an example:

I arbitrarily chose Angola. Two navbars at the bottom. You over over "e" for each and it says "edit this template". Let's assume we institute the above suggestion. Now we have two templates that each say "edit this page", implying that you're editing Angola instead of Template:Angola topics or Template:Countries of Africa.

This is why I started arguing semantics, because while I agree that "this template" is nonspecific should we happen to have a template being transcluded from somewhere other than the Template space, but again I would argue that a userspace template (or even a WikiProject template) is still a "template" in that it gets transcluded from one place to another, especially if it's using {{navbar}}. Primefac (talk) 19:45, 20 September 2017 (UTC)

No, I didn't mean that it should always be "page", nor that it should change depending on where it was transcluded to: but should change according to the namespace where the navbar is actually used. So for example in Angola, we have {{Angola topics}}; and this is hosted in Template: namespace, so the link's title attribute correctly uses the word "template". If, for some reason, the code which begins
{{Country topics
| country = Angola
| state = {{{state|{{{1|autocollapse}}}}}}
| adjective = Angolan
were not in template space, then it would be appropriate to show the word "page". What I am saying is that the line
				:attr('title', 'View this template')
might be altered to something along the lines of
				:attr('title', 'View this '+if(namespace(args.navbar)=10,'template','page'))
But as I say, I'm no Lua expert. --Redrose64 🌹 (talk) 20:34, 20 September 2017 (UTC)
Or something. This Lua code is all unreadable; I can't track it through at all - and this module is quite small. RexxS, how the heck does the first positional parameter of Template:Navbar get converted into title.fullText for the "view" link? Let's not worry about the other two at this stage. --Redrose64 🌹 (talk) 20:55, 20 September 2017 (UTC)
@Redrose64: In Module:Navbar at line 19, you find:
  • local titleText = args[titleArg] or (':' .. mw.getCurrentFrame():getParent():getTitle())
The previous lines set titleArg to 1 or 2 depending on whether it's 'collapsible' and/or 'plain', so that either the first or second positional parameter (i.e. args[1] or args[2]) is used to set titleText (args[titleArg]).
If that parameter does not exist, then the or sets titleText to a colon plus the title of the page from which the template is called (':' .. mw.getCurrentFrame():getParent():getTitle())
Line 20 then creates a "title object" called 'title' representing the given title in the 'Template' namespace, and lines 22-24 throw an error if that is not a valid title.
Line 26 sets a variable 'talkpage': if the page can have a talk page, it is a string containing the title of the page, with the namespace and interwiki prefixes and the fragment; otherwise it is nil.
The documentation for the mw.title.new function is at mw:Extension:Scribunto/Lua reference manual #Title objects.
Lines 54 onwards create a <div>...</div>, within that is an <ul>...</ul> containing <li>...</li> - the first of which (on lines 57-66) uses title.fullText, which is the title of the page corresponding to the 'title' object created in line 20 (with the namespace and interwiki prefixes and the fragment per documemtation of .fullText).
Is that what you wanted to know? --RexxS (talk) 23:07, 20 September 2017 (UTC)
The problem still becomes one of language, and being specific. Let's use your Country topics example - if it were not in the template space, and it said "edit this page", it would still have a dual meaning - edit the article you're looking at, or edit the page where this "template" is found? I can understand the concerns raised, but (to quote H:T) a template is a Wikipedia page created to be included in other pages. If something is actively being transcluded onto multiple pages, it's a template (especially if it's using {{navbar}}).
Now, if we come up with a way (in two words or less) to accurately describe "edit this X" that will inform the user that they will be editing a different page (regardless of namespace) then I'm happy to make that change to the module. At the moment, though, I'm just concerned that we're trying to delineate the spades from the shovels. Primefac (talk) 13:05, 21 September 2017 (UTC)
Perhaps we could use the wording "Edit this navbox"? I would assume that anyone competent enough to edit the particular instance of the navbox would be well enough informed to understand what the 'navbox' would be. --RexxS (talk) 20:41, 21 September 2017 (UTC)
That would be acceptable, and I almost implemented the change, but then I noticed that {{Deletion tools}} uses it as well, as do some other sidebars and portals. Philosophically, can we call a sidebar a navbox?Primefac (talk) 21:17, 21 September 2017 (UTC) I also just found that {{Public domain copyright templates}} uses this template Primefac (talk) 21:19, 21 September 2017 (UTC)
Well, it's not my call, and I'm not trusted to edit this template or its module, but I'd simply enable another parameter that defaults to "template" when absent. Then use that in the hover-tip, something like:
tooltip = args.tooltip
if not tooltip or #tooltip == 0 then tooltip = "template" end
...
   :attr('title', 'View this ' .. tooltip)
etc.
Then anyone could modify the tooltip to "View/Discuss/Edit this navbox or sidebar or whatever" according to taste. It's not going to be moved away once it's placed on a page, so it doesn't really need to dynamically determine what it's being used in and a editor only needs to make that call once. --RexxS (talk) 22:22, 21 September 2017 (UTC)
Thanks RexxS, that's going to do the job that I was thinking of using another method for. --Redrose64 🌹 (talk) 23:31, 21 September 2017 (UTC)

Color accessibility issue in V*T*E links on standard navbox title color[edit]

I discovered that the wikipedia red link color on the standard navbox title color does not obey the WCAG 2.0 standards for text color contrast below 18pt. Not sure what to do about this. I started a discussion about this at WT:WikiProject Accessibility#Wikipedia red link on wikipedia standard navbox title violates WCAG 2.0, feel free to join in. —hike395 (talk) 07:01, 3 January 2018 (UTC)

Why is this page protected?[edit]

Why have you put this page under protection and why is everything hidden? Is that to stop people from posting all the music that jamiroquai have stole on those guys music list? — Preceding unsigned comment added by Amir 86302 (talkcontribs) 18:13, 26 March 2018 (UTC)

Amir 86302, I think you're posting in the wrong place. This page is protected because it is used on nearly 8 million pages, but it has nothing to do with music. Primefac (talk) 18:18, 26 March 2018 (UTC)

Merging in of View and V[edit]

So I've coded the merge in of Template:V and Template:View at Module:Navbar/sandbox. Thankfully nothing horrible with the code; I have a few notes:

  • {{v}} technically allows to do say {{v|e|t|template = v/doc}} to produce , i.e have a different order of view talk and edit etc; the way I've coded it always has the same order regardless of how it is inputed; it'd be more complicated to code it the other way, and it seems reasonable to have a consistent ordering
  • one can also mix mini and non-mini with {{v}} e.g {{v|edit|t|template = v/doc}} gives . Similarly limited
  • If {{view}} is just redirected to the new version of {{navbar}}, then this breaks the cases of {{view|v/doc}}, i.e, the ones without |template= by giving instead of . There isn't really any way to fix that
    And anyhow, one'd have to have |plain=1 on each instance of {{view}} thus both {{v}} and {{view}} should probably just be convenience wrappers for {{navbar}} rather than redirected, as I've done on {{v/sandbox}} and {{view/sandbox}}. Either that or someone needs to fix the instances where |template= isn't given and add |plain= and |mini= as appropriate.

@Primefac, Train2104, and Frietjes: the participants of the TFD for their thoughts Galobtter (pingó mió) 08:12, 2 April 2018 (UTC)

Protected edit request on 7 April 2018[edit]

Copy the sandbox (revision) to complete the merger of {{v}} and {{view}} as described above. Tested at Template:Navbar/testcases, Template:Navbox/testcases, and Module:Navbar/testcases; and Template:V/testcases for the new functionality Galobtter (pingó mió) 07:55, 7 April 2018 (UTC)

 Done Galobtter, am I to assume this means that {{v}} and {{view}} can be redirected here? Primefac (talk) 12:43, 9 April 2018 (UTC)
Primefac the explanation is above - you'd first need to add some parameters to all transclusions if one wanted to do that - as they are formatted differently - |plain= and |mini= would need to be set Galobtter (pingó mió) 13:31, 9 April 2018 (UTC)
Ah, right, totally helps to actually read previous discussions. I'll get on it. Primefac (talk) 13:35, 9 April 2018 (UTC)

Protected edit request on 9 April 2018[edit]

Revert last edit to Module:Navbar! HIGHLY-visible template is bugged because of the last edit done by Primefac! wumbolo ^^^ 12:57, 9 April 2018 (UTC)

FYI - looks like this error is stemming from sidebar style templates. SFB 13:04, 9 April 2018 (UTC)
Came here to report Inflation_(cosmology). --Izno (talk) 13:08, 9 April 2018 (UTC)
fixed here. Frietjes (talk) 18:10, 9 April 2018 (UTC)
If the aim of that edit was to remove global variables, another local is needed on line 52: num = index[v] Johnuniq (talk) 23:37, 9 April 2018 (UTC)
Done. Primefac (talk) 17:56, 10 April 2018 (UTC)

Navbox without v - t - e possible?[edit]

The title says it all: Is it possible to create a navbox without the v-t-e part on the top left or can that not be done due to dependencies to the navbar and v templates? If it is not possible, is there something similar you could recommend as some kind of infobox that spans over the top of a page? — Preceding unsigned comment added by Lithimlin (talkcontribs) 17:54, 17 April 2018 (UTC)

Lithimlin, if you are planning on using {{navbox}}, then yes, it will have the v-t-e. What sort of instance would you want a navbox without it (i.e. please give an example)? Having a navbox without the ability to easily find and edit it would be problematic. Primefac (talk) 17:56, 17 April 2018 (UTC)
(edit conflict)Putting |navbar=plain when creating a template with {{navbox}} will disable the navbar; though indeed as Primefac says that it'd be better to know what you're using it for Galobtter (pingó mió) 17:59, 17 April 2018 (UTC)
Huh. Learn something new every day. Primefac (talk) 18:04, 17 April 2018 (UTC)
As I said, I basically just want to make an infobox, that is not on the right side with a fixed width, but rather at the top of the page, spanning across it. Lithimlin (talk) 18:20, 17 April 2018 (UTC)
Well, it looks like you can. If you run into issues feel free to drop at note at WT:WPT. Primefac (talk) 18:22, 17 April 2018 (UTC)
Will do so. Thank you. Lithimlin (talk) 18:24, 17 April 2018 (UTC)
If you are using the {{navbox}} template, and you want the v-t-e links omitting, all you need to do is omit the |name= parameter - or leave it blank. No need for any |navbar=plain etc. --Redrose64 🌹 (talk) 18:46, 17 April 2018 (UTC)
Redrose64 You mean the |title= parameter, right? Lithimlin (talk) 19:02, 17 April 2018 (UTC)
No, I mean the |name= parameter. That has just one purpose: to set the v-t-e links. If that param is blank or absent, there are no links. --Redrose64 🌹 (talk) 19:35, 17 April 2018 (UTC)
I just tried it and not setting a {{{name}}} didn't change anything. However, if there's no {{{title}}}, there will also not be any v-t-e links. Lithimlin (talk) 19:38, 17 April 2018 (UTC)
Where are you testing this? It would help a lot more if we could see what you're attempting. Primefac (talk) 19:39, 17 April 2018 (UTC)
I'm testing this in a wiki I'm helping to put together right now. I'm kind of misusing the {{navbox}} here, but it was the only thing I found so far that can be used as an {{infobox}} that spans across the top of a page instead of being on the top right of it.
Right, all bets are off. This is the English Wikipedia, and this page, Template talk:Navbar is for discussing improvements to the template Template:Navbar at English Wikipedia. Nothing else. --Redrose64 🌹 (talk) 19:46, 17 April 2018 (UTC)
Yes, this can be closed, as the original problem has been explained. Lithimlin (talk) 19:48, 17 April 2018 (UTC)

Make tooltips optional so "sortable" doesn't break in sports tables?[edit]

Sports tables, like this one, can't be sortable. A comment in the Module:Sports_table says the problem is caused by Navbar and gives a link to this comment, which says "It's caused by {{navbar}} adding tooltips to the link text with <abbr title="Discuss this template">t</abbr> instead of just t. There is no current option to omit the tooltips but it could be requested at Template talk:Navbar."

So, to fix Module:Sports_table, could someone add that option to Navbar? Other solutions for Module:Sports_table would also be welcome. Thanks. Great floors (talk) 15:02, 29 July 2018 (UTC)

Great floors Making that table sortable, as I did here, seems to work fine. That bug would only affect tables with navbars, of which this isn't Galobtter (pingó mió) 15:41, 29 July 2018 (UTC)
Thanks! I've made a start now at fixing Module:Sports table (which was either out of date or just very incomplete). Great floors (talk) 17:53, 29 July 2018 (UTC)

Add purge[edit]

Would it be possible to get an option added to this so that a `purge` link could be added? --Zackmann08 (Talk to me/What I been doing) 20:50, 17 September 2018 (UTC)

Zackmann08 if you open your "Preferences" page and go to the "Gadgets" section you will find a couple options for adding a purge link to pages. Frietjes (talk) 14:37, 18 September 2018 (UTC)
Frietjes as always, you rock. :-) --Zackmann08 (Talk to me/What I been doing) 16:43, 18 September 2018 (UTC)

Request: Add template styles to existing stylesheet[edit]

Please add:

<templatestyles src="Navbar/styles.css" />

to this template. This will allow us to manage styles for mobile and desktop in one central place and remove them from MediaWiki:Mobile.css. Navbar's are not present on all pages so this would reduce the amount of CSS we ship to users. Jdlrobson (talk) 23:18, 30 October 2018 (UTC)

This should be done in Module:Navbar. Change sandboxed Galobtter (pingó mió) 05:05, 31 October 2018 (UTC)
See Module talk:Navbar/testcases, Template:Navbar/testcases, and Template:Navbox/testcases. Galobtter (pingó mió) 05:11, 31 October 2018 (UTC)
What is extensionTag doing? I have a rough idea of its function but without knowing much about templatestyles I would have thought that adding the wikitext shown above was what was wanted. Just curious, was there a reason no_globals was removed from the sandbox in April? Possibly because navbar was used with other modules that had globals? At any rate, the frame variable should be declared local. Johnuniq (talk) 06:41, 31 October 2018 (UTC)
Thanks for the catch on the local variable! (apparently I still haven't learnt my lesson from last time..). Reason I removed; wasn't sure if the final code I should have Module:No globals (this module is used in so many places that it could possible break something..), but should definitely test in sandbox to make sure there are no globals. Regarding extensionTag, It is the same thing as using {{#tag:templatestyles||src = "Navbar/styles.css"}} which would do basically the same as
<templatestyles src="Navbar/styles.css" />
Galobtter (pingó mió) 07:11, 31 October 2018 (UTC)
I added no globals to the testcases so that should be tested there at-least. Galobtter (pingó mió) 07:18, 31 October 2018 (UTC)
OK, but I think you are saying there is no reason to use extensionTag. Just add the wikitext without the complexity/overhead of calling extensionTag. Johnuniq (talk) 08:39, 31 October 2018 (UTC)
You'd have to do frame:preprocess{'<templatestyles src="Navbar/styles.css" />'} which has no less complexity/overhead. Galobtter (pingó mió) 08:51, 31 October 2018 (UTC)
Ah, now we're getting to my question. Why does the tag need to be preprocessed? I understand that preprocessing is needed if you want a template expanded but in my innocence I thought the plain wikitext of templatestyles would do. I don't have an idea of when/how it loads the required css. Why would preprocessing help with that? Perhaps I should go to WP:VPT. Johnuniq (talk) 09:03, 31 October 2018 (UTC)
Johnuniq if it isn't preprocessed it'll just show the bare text like <templatestyles src="Navbar/styles.css" /> ({{#invoke:Sandbox/Galobtter/preprocess|main}} gives <templatestyles src = 'Flowlist/styles.css'>)
This is because mw:Extension:Scribunto/Lua_reference_manual#Returning_text: "At this point in the page parse, templates have already been expanded, parser functions and extension tags have already been processed, and pre-save transforms (e.g. signature tilde expansion and the pipe trick) have already happened." So when Lua returns the text it won't have the regular processing be done on it, including processing tags; so it needs to be preprocessed. Galobtter (pingó mió) 09:09, 31 October 2018 (UTC)
When the templatestyles tag is preprocessed it'll be replaced with a strip marker and then later turned into the style html (which one example is like this:
<style data-mw-deduplicate="TemplateStyles:r856588462">.mw-parser-output .module-shortcutboxplain{float:right;border:1px solid #aaa;background:#fff;margin:0 0 0 1em;padding:.3em .6em .2em .6em;text-align:center;font-size:85%;font-weight:bold}.mw-parser-output .module-shortcutlist{display:inline-block;border-bottom:1px solid #aaa;margin-bottom:.2em;font-weight:normal}.mw-parser-output .module-shortcutanchordiv{position:relative;top:-3em}</style>
if you're curious.) Galobtter (pingó mió) 09:12, 31 October 2018 (UTC)
Thanks for those details. That's pretty weird! We have something that looks like html (the templatestyles wikitext) but it gets expanded. I suppose I'll get used to it. Johnuniq (talk) 09:33, 31 October 2018 (UTC)
@Johnuniq: The HTML-like appearance of <templatestyles /> should not be unfamiliar: consider <ref name=something>...</ref> which is found in so many articles; this looks like HTML (but is not HTML), it's part of the cite.php extension to the MediaWiki software. Then there are <gallery>...</gallery>, <math>...</math>, <noinclude>...</noinclude>, <nowiki>...</nowiki>, <references /> and <syntaxhighlight>...</syntaxhighlight> (which is used above), all of which are either part of MediaWiki, or are coded as extensions to it. There are several others - I won't list them, there are at least twenty in all. --Redrose64 🌹 (talk) 12:10, 31 October 2018 (UTC)
True. I guess my mental model of when things happen is faulty. I was imagining that <ref> and friends would be handled in some final stage of rendering, but on reflection I have seen that a ref is a strip marker by the time a module gets its input. I suppose the rendering that I hadn't thought about is exactly the step which expands templates/modules and so is the last chance to expand other things like templatestyles. Thanks all. Johnuniq (talk) 23:58, 31 October 2018 (UTC)

Template/module for ptwiki[edit]

I'm trying to implement this template/module on ptwiki, but there is this bug where it works fine in most cases, except for "edit" and "Edit this template" when it's used with {{V}} and {{View}} (and I suppose the same for "hist" and "watch"). Instead of displaying text in Portuguese, it instead displays it in English. I was thinking someone could help me out. Here's the testcase page on ptwiki. —CaiusSPQR (talk) 17:58, 19 March 2019 (UTC)

Never mind, everyone. I just figured it out. It was a problem with the V and View templates. —CaiusSPQR (talk) 18:35, 19 March 2019 (UTC)

A little technical problem[edit]

You know those drop down templates found at the bottoms of articles, such as Template:Xiamen? Also know how there are three buttons at the top left on all of them that say "V", "T", and "E", for "view", "talk", and "edit"? I'm on Chrome on a Huawei phone, and none of the buttons work at all. Pressing them only brings up descriptions of the buttons, "edit this template", etc. I can still edit them of course, but it's kind of inconvenient. How do I fix this? Woshiyiweizhongguoren (🇨🇳) 11:17, 28 March 2019 (UTC) (Originally asked at the Teahouse and the Village Pump but later moved here)