User:NYKevin/Template editing
This is an essay. It contains the advice or opinions of one or more Wikipedia contributors. This page is not an encyclopedia article, nor is it one of Wikipedia's policies or guidelines, as it has not been thoroughly vetted by the community. Some essays represent widespread norms; others only represent minority viewpoints. |
This page in a nutshell: If you want a template to behave a certain way, just change it. All you need to do is
|
This user page or section is in a state of significant expansion or restructuring. You are welcome to assist in its construction by editing it as well. This template was placed by Thinboy00 (talk · contribs). If this user page has not been edited in several days, please remove this template. If you are the editor who added this template and you are actively editing, please be sure to replace this template with {{in use}} during the active editing session. Click on the link for template parameters to use.
This page was last edited by Useight (talk | contribs) 14 years ago. (Update timer) |
Templates are often considered "untouchable," or nearly so. This is because they appear on a large number of pages. Obviously, if you edit one, your changes will appear on a large number of pages. Because this is such a large scale change, the tiniest of additions are often looked down upon simply because people may be surprised by a sudden change in functionality. Clearly, surprising people like that is undesirable, but templates don't always have the exact functionality you want.
Just edit them...
editI feel people should just edit templates when they want to add functionality. If a template was not "supposed to" be edited, it would be protected. If you want to add functionality to a template, just do it. No one will arrest you, no one will revert you, and if you do it well, no one will complain.
...But not recklessly
editSuppose that a sysop accidentally deleted {{refimprove}}
and {{citations missing}}
(a TfD over the latter was recently closed as no consensus, and it may become deprecated). Other sysops either are unaware, or wary of reverting their fellow sysop's change, for fear of a wheel war (this is necessarily an extreme example). So the templates remain deleted for, say, several days. The only option for new uses of the templates is {{unreferenced}}
. It does not make sense to edit that template to fill in the gap left by the others because it would surprise people unaware of the change and mess up old articles. On the other hand, there is a way to edit that template to temporarily fill the gap without surprising people
So how to edit them?
editInvent a new parameter. For this example, let's call it "somerefs" because it is set to indicate the article has some, but not enough, refs. Here's what you'd do: replace the relevent text of the template with:
{{#if:{{{somerefs|}}}|put the text for not enough refs here (desired new text)|put the text for no refs (the old text) here}}
In that case, if someone does not set somerefs (as they didn't in the old articles), they get back ordinary behavior. If they don't know about somerefs, we can expect them not to set it (in general, setting parameters you are not familiar with is a bad idea), and in that case, they can expect normal behavior. If they do, they can choose what makes sense.
So this is always a Good Thing, right?
editWrong. If you put a lot of unneeded ParserFunctions (that's what the {{#if:...}}
is) into a template, people will have trouble understanding how they work.
The definition of sanity
editYou should only edit a template this way if it will help in at least one case. Even then, if a template has {{esoteric}}
on it, be cautious about making it more esoteric. Nevertheless, don't let esotericness stop you. Just use its sandbox first, since with such a complex template, it's easy to make a mistake. If an edit will help in many cases, it's probably safe. If an edit will help in one unique case and possibly others, make the change generic. For an example, see my edit to {{User meta}}
. I added a parameter to allow people to change the phrase "a page" to other things. I could have added a simple toggle, like you see above, but that would be less generic and less widely usable. On the other hand, in the above case, the text is lengthy, and the benefits of genericness are outweighed by its potential problems (if every single page had its own custom version of {{refimprove}}
, that would be a Bad Thing).
Make a new template, or retool an old one?
editIn some cases, it is more beneficial to simply make a new template. The previous example is not really a realistic occurrence, since sysops don't leave their mistakes sitting around for several days, and compromised accounts are usually blocked and desysopped relatively quickly, after which the damage may be undone. In the above case the long term solution would be to undelete {{refimprove}}
. But suppose you wanted to merge the ref templates to make a Grand Unified ref template. Here's a basic skeleton:
{{ambox| type={{#ifeq:{{{zone}}} | footnotes|style|content}}| image={{#switch:{{{zone}}} | footnotes=[[Image:Text document with red question mark.svg|50px]]|references=[[Image:question book-3.svg|50px]]|#default={{ns:0}} }}| text=<div><!-- div used to escape |, }}, etc. --> {{#switch: {{{zone}}} |references = {{#switch:{{{level|none}}} | none = /unreferenced text/ | few = /refimprove text/ | /unreferenced text/}} |footnotes = {{#switch:{{{level|none}}} | none = /nofootnotes text/ | few = /morefootnotes text/ | /nofootnotes text/}} |/citations missing text/}}</div> }}
You could then place it at {{citations missing}}
since it defaults to show the text of {{citations missing}}
. You could transclude it into all the other templates as a replacement for their raw wikicode. No one would even notice on the old articles using them, but it would make it easier to insert the appropriate template, without having to hunt for it.
Affected templates
edit{{unreferenced}}
{{refimprove}}
{{nofootnotes}}
{{morefootnotes}}
{{citations missing}}
Pros
edit- One name for all four specific templates (
{{citations missing}}
is far too generic to count as a "specific template," but makes a great name, as it is true of all four cases) {{citations missing}}
doesn't have to be redirected/deleted, both of which are seen by some as suboptimal outcomes- NO MASSIVE CLEANUP!!! (i.e. you don't have to do a thing to the thousand or so articles these templates are used on to implement this full scale)
{{citations missing}}
has a purpose in life, namely, to serve as the default should someone be careless/lazy- Discourages use of
{{citations missing}}
with appropriate{{documentation, template}}
and provides alternatives. When none are appealing, they may be added via{{sudo}}
if/when consensus is reached, with little announcement necessary, just add them to the docs as param options, and in the meantime, the generic form may be used with appropriate commenting on the affected article's talk page. - Demonstrates why
{{citations missing}}
in its current form is redundant and vague.
Genericness
editTo make generically customizable text:
{{{newparam|old text}}}
The user now sets newparam to desired text. If not set, the old text is the default.