Help talk:Advanced templates
Add topicIncluding the content of a template in a template or variable name or parameter value
[edit]According to this section, this has been possible since 19 October 2005. I have just upgraded to MediaWiki 1.5.1 which was built after this date, however I cannot include templates within the parameters of other templates. DO I need to grab specific files out of CVS? -- Colin E.
- The description refers to the version Wikimedia uses, which is now 1.6alpha.--Patrick 00:23, 3 November 2005 (UTC)
Help with Missing Parameters
[edit]I'm a programmer, and I find these templates so esoteric it's impossible to use them. So I'm asking for help. I want to make an infobox template that has an image file name as a parameter, among others. If the image name is missing, I want to omit some of the text from the template (a table row). If you can give me a simple example I'll be grateful, either here or on my Talk page. If there's a better forum for this request, please let me know. Thanks very much, —Papayoung 71.208.44.105 22:20, 29 September 2005 (UTC)
- Handling missing parameters is not possible, handling blank ones is. See Template talk:Ine.--Patrick 01:05, 1 October 2005 (UTC)
- You're wrong! See below :-P R 21:38, 20 October 2005 (UTC)
Change in syntax
[edit]There's just been a very important change concerning templates.
- There is now a syntax to define a default value for parameters, which is used when the parameter is undefined. It has the form {{{param|default value}}}.
- It is now possible to use templates in parameter values.
Thus, a significant part of this page must be rewritten! R 21:36, 20 October 2005 (UTC)
Little correction
[edit]Following excerpt is not exacty true:
It is not possible to use a template with a name dependent on the content of another template.
- For example: {{{{tctc}}}} is trying to include a template on a page, using the text in Template:Tctc containing "
tc
" to get the name of the template. However, {{{{tctc}}}} simply gives the text {{{{tctc}}}}, not the content of Template:tc containing "in<noinclude>{{documentation}}</noinclude>
".
Example is correct, but statement "It is not possible to use a template with a name dependent on the content of another template" is incorrect as from 19 October, 2005 it is possible to make template name depend on value of other template, you just need to separate closing parentheses with a space or '|' ({{{{tctc}}|}} or {{{{tctc}} }} or {{ {{tctc}}}}). Knutux 09:21, 24 October 2005 (UTC)
- Thanks, I changed it.--Patrick 19:30, 24 October 2005 (UTC)
Retrive parameter depending on other parameters value
[edit]- I found that {{{{{{1}}}}}} works, I used it to make an equal-function, see w:Template:Booleq --AzaToth 20:49, 23 November 2005 (UTC)
- Simlar I used it in w:Template:Switch AzaToth 20:55, 26 November 2005 (UTC)
Is that in 1.5.x or in 1.6alpha?
Cleanup
[edit]This help page needs a major cleanup I think AzaToth 15:36, 2 December 2005 (UTC)
- I agree. This "documentation" borders on incoherent. ‣ᓛᖁᑐ 16:42, 16 December 2005 (UTC)
- Agreeing, and adding the cleanup tag. (I don't know how much the page has changed in the last year, but the above comments still seem to apply.) -Starwed
Difference between writing parameters directly or keeping them in a template
[edit]I have a small problem. If I have a template and define a parameter in it on the page I'm using it on, I can also define other parameters, which the template doesn't use, without its showing on the page. However, if I keep the definitions in another template, it insists on listing all the other, unused parameters on the page. Why is that?
Let me explain it to make you understand it better (this is an extreme simplification of my situation):
I have a template called Do. It contains the following: Start-{{{Parameter1}}}-end. If I use it on a page by writing {{Do|Parameter1=Middle}} it will of course show up on the page as Start-Middle-End. I can also define a lot of unused parameters, so as to write {{Do|Parameter1=Middle|Parameter2=To|Parameter3=Till}} and it still will show up on the page as Start-Middle-End. So far so good. However, if I define all these parameters in another template called Do Definitions (which then contains Parameter1=Middle|Parameter2=To|Parameter3=Till) and I use the template Do by writing {{Do|{{Do Definitions}}}}, shouldn't the Do template interpret this as {{Do|Parameter1=Middle|Parameter2=To|Parameter3=Till}}? It doesn't seem to, since it turns up on the page as Start-Middle|Parameter2=To|Parameter3=Till-End. Why is that? Can't I use another template in which I define a lot of unused parameters (for other use)? In short: If I have written something in a template and include it in another template, why doesn't the second template interpret the text in the first template exactly as if I had written the text in the second template? /85.224.55.111 15:48, 20 January 2006 (UTC)
- I added this to Help:Advanced_templates#A_template_containing_an_assignment_of_a_parameter_value_to_a_parameter_name. Apparently identifying separate parameter assignments is done before evaluating templates in each.--Patrick 00:09, 23 January 2006 (UTC)
Mimicking a database table
[edit]In the w:Polyhedron pages we have a number of pages where the same information is repeated in several places. We would like to do this as there are several different views of the subject which group the data in different ways exhibiting different relationships e.g. w:List of uniform polyhedra by Wythoff symbol, w:List of uniform polyhedra by vertex figure and w:List of Wenninger polyhedron models. We have 75 different polyhedra we would like to display which have about 10 properties each.
Rather than try to maintain all the data in the different pages allowing lots of transcription errors, we've though of using a simple database approach. I've tried two different approaches, one using a {{switch}} and one with a sort of callback mechanism. An example of this can be found at w:User:Pfafrich/test.
In the callback version there is one template per polyhedron. For example w:Template:Polyhedra T contains
{{{{{1}}}|name=Tetrahedron|image=tetra.png|....}}
Theres also a few different templates defining how the polyhedron is displayed w:Template:Polyhedra row contains code like a normal info box
<tr><td>[[{{{name}}}]]</td> <td>[[Image:{{{image.png}}}]]</td></tr>
To call it we use code like
{{Polyhedra T|Polyhedra row}}
In the switch verion there one template with the data
{{switch|{{{poly}}} |case: T name=tetra|case: TF=4|case: TE=6|case: TV=4 |case: O name=octa|case: OF=8|case: OE=12|case: OV=6 |case: H name=hexa|case: HF=6|case: HE=12|case: HV=8 |case: I name=icosa|case: IF=20|case: IE=30|case: IV=12 |case: D name=Doceca|case: DF=12|case: DE=30|case: DV=20 }}
An another w:Template:User pfafrich test chi which displays the data
'''{{User pfafrich test|poly={{{1}}} name}}''' Faces: {{User pfafrich test|poly={{{1}}}F}} Edges: {{User pfafrich test|poly={{{1}}}}E}} Vertices: {{User pfafrich test|poly{{{1}}}}V}}
This uses a composition of parameter values and a lot of calls to switch. This would be called like
{{User pfafrich test chi|T}}
I'm wondering which technique is better in terms of server load. I've a feeling the callback method is more elegant. However it would be easier to have the data in one big table, rather than in 75 different templates.
Anyone have advice on a nice way to do this? --Salix alba 02:06, 22 January 2006 (UTC)
I must admit that I'm suprised Wiki doesn't do lookups very well. I have a system where I want to display the same information on several pages that are related to each other so I have to either manually edit each of those pages or I put the common stuff onto a template page. This is OK when you are only talking about a few templates but when you get up to over 200 templates its a complete pain to maintain. I'd love to be able to have ONE template that I pass a parameter to and that returns the common data for that parameter Steve A 15:49, 20 February 2006 (UTC)
- I've now found quite a nice way to do it. The page w:List of uniform polyhedra by Wythoff symbol is mainly built from data stored in w:Template:Polyhedra DB and displayed using w:Template:Polyhedra smallbox2.
Each polyhedron is included with code like
{{Polyhedra DB|Polyhedra smallbox2|T}}
Where T
is the name of the polyhedra, in this case Tetrahedron.
w:Template:Polyhedra DB is like
{{{{{1}}}|{{{2}}}| |T-name=Tetrahedron|T-image=tetrahedron.jpg| # name and image |T-V=4|T-E=6|T-F=4| # number of corners, edges and faces # other data omitted |O-name=Octahedron|O-image=octahedron.jpg| ... }}
The data is encoded like T-image=data
where T
is the name for lookup (i.e. row), and image
is particular property (i.e. column).
The first two parameters to this template just pass their arguments through, so this resolves to
{{Polyhedra smallbox2|T|T-name=Tetrahedron|....}}
and means that the Polyhedra smallbox2
template is included. Now Polyhedra smallbox2
is like:
[[Image:{{{{{{1}}}-image}}}|100px]]<BR> [[{{{{{{1}}}-name}}}]]<BR> V {{{{{{1}}}-V}}},E {{{{{{1}}}-E}}},F {{{{{{1}}}-F}}}
so with the first parameter T
this becomes
[[Image:{{{T-image}}}|100px]]<BR> [[{{{{T-name}}}]]<BR> V {{{T-V}}},E {{{T-E}}},F {{{T-F}}}
Just like a standard infobox template. The system is quite flexable as different display templates can be used to display different data. --Salix alba 00:23, 14 March 2006 (UTC)
A parameter name depending on a parameter
[edit]In this section, I found the very neat options template (Do if parameter is empty and Do if parameter isn't empty). Can this be done in the way of Do if parameter contains a and Do if parameter contains b instead? I can't figure it out for myself. /85.224.55.111 22:40, 23 January 2006 (UTC)
- No, there is no "contains" function/relation.--Patrick 00:14, 22 February 2006 (UTC)
Using Templates in Extensions
[edit]I am using an iframe extension because I would like to include the Amazon iframes on my main pages for books and movies. Is it possible for me to put the basic iframe code in a template and then call the template passing only the isbn number and have it correctly insert the parameter in the iframe?
My template code is as follows:
<iframe> url=http://rcm.amazon.com/e/cm?t=epinionaddicts&o=1&p=8&l=as1&asins={{{asin}}}&fc1=000000&IS2=1<1=_blank&lc1=0000ff&bc1=000000&bg1=ffffff&f=ifr width=120px height=240px name=amazon </iframe>
And, I would like to call it like this:
{{Amazon | asin=0393324826}}
But, when I do this, the iframe shows without the parameter being in its proper place. The asin never seems to be parsed.
Am I missing something?
Hyperlink in a template included in a template
[edit]Hello,
after upgrading to wikimedia 1.6.1 I tried to use the "template in template" functionality. Everything is OK except for the following example.
I use the example {{x3|{{x5|{{tc}}}}}} from the section Including the content of a template in a template ...
I modify the example to {{x3|{{x5|[http://service.sap.com/~form/handler?_APP=01100107900000000342&_EVENT=REDIR&_NNUM= SAP]}}}} and get this {{{1}}}{{{1}}}{{{1}}}{{{1}}}{{{1}}}{{{1}}}{{{1}}}{{{1}}}{{{1}}}{{{1}}}{{{1}}}{{{1}}}{{{1}}}{{{1}}}{{{1}}}.
I am not sure about the cause, but I think it´s something with the Hyperlink, cause {{x3|{{x5|[http://www.google.de Google]}}}} is working fine (GoogleGoogleGoogleGoogleGoogleGoogleGoogleGoogleGoogleGoogleGoogleGoogleGoogleGoogleGoogle).
Any ideas? tia, Marcus
Returning just first letter of a parameter?
[edit]I've been wondering if this is even possible. Say I have a template which accepts 3 parameters. I want to take one of those parameters, and use just the first letter, while still keeping the parameter intact for further use.
Can it be done? - Superwad
- You might want to check the StringFunctions extension. - Manu3d 09:43, 11 July 2007 (UTC)
Optional table row
[edit]I'm trying to make a template that has table formating(IE Background and Border Colour) and changes depending on what someone enters.
The Table Code is this:
{| |- ! colspan="3" style="border:1px solid #a3bfb1; background:#cef2e0;"| Persons Name : | style="border:1px solid #a3bfb1; background:#f5fffa;"|{{{name}}}. |- ! colspan="3" style="border:1px solid #a3bfb1; background:#cef2e0;"| Person's place of Birth : | style="border:1px solid #a3bfb1; background:#f5fffa;"|{{{Place of Birth}}}. |}
So if someone wanted to use this, they only have to enter:
{{Template Person |name= Bob |Place of Birth= Far Away }}
And it will show that information. But could someone tell me is it possiable to make it so if someone puts only name, the place of Birth row in the table dosn't show?
With Place of Birth | With Out Place of Birth | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
Please bare with me, I'm still learning... And sorry if this isn't the right place...Didn't know.
- A special Template:! is used, and ParserFunctions, use the second wikitext (here showing the result with undefined parameter), the first shows what you get when the parameter is defined:
Persons Name : | Bob. | ||
---|---|---|---|
Person's place of Birth : | Far Away. |
Persons Name : | Bob. |
---|
- Thank you for the help.
- Hi, I am also interested in the optional table row but don't quite understand the above statement. Could anyone help me out?
Thanks - RM
Template for: Is this article belong to a specifiv category
[edit]Can one write a template in order to find out, whether the current article belongs to a specific category? JanCK 23:47, 21 October 2006 (UTC)
Link to information on #if, #expr etc.
[edit]An anonymous IP user changed a link in the first paragraph from "Parserfunctions" to "Parser function" with edit summary "fixed broken link". The "Parserfunctions" link which I originally put in works for me and leads to a page with information on "#if:" and "#expr:" etc. which is needed for anyone wanting to do template programming. The link "Parser function" leads to a different page. Both links are needed, and the "Parser function" link was already given in the previous sentence. I'm putting back the link I originally put in. --Coppertwig 12:33, 3 April 2007 (UTC)
Variable number of parameters
[edit]I'm trying to make a few templates that essentially amount to differently formatted Q&A pages. They're prime for templates because they're all basically the same thing repeated over and over: A bunch of question and answer combos in a common format. So, obviously, the question should be a template, the answer should be a template, the Q/A combo should be a template made up of the question template and answer template, and then the entire Q&A page itself should be a template made up of some number of Q&A combo templates.
The problem is that some Q&A pages may have 5 Q/A combos, some 10, some 100. So here's the problem: Is there any way to make a template that can have 1 to n possible parameters without doing hundreds or thousands of lines of {{#if: {{{1|}}} | do stuff}} {{#if: {{{2|}}} | do more stuff}} ... {{#if: {{{250|}}} | do even more}}?
I've seen Template:for, and I know how to use it directly (like make a table on one page with a variable number of rows/cells), but I'm not really sure how to incorporate that into a template to be used on multiple pages; I.e. pass the Q&A template a random number of anonymous parameters which it then passes to Template:for, which calls the Q/A combo template once for each. The only way I can see to do it is to take the actual code from Template:for and implement it in every single template that could have a variable number of parameters, which is a terrible solution.
Any suggestions would be appreciated. --20.4.235.68 20:28, 2 December 2009 (UTC)
Use values from included templates?
[edit]How can I include the value of a used template from an article in another article? For example, the Wikipedia article "Alfred Hitchcock" uses the Persondata template. In another article, I would like to insert the date of birth that is given in that article. If it is not possible using the template technique, does anyone know of an extension that is capable of doing so?
- Anyone?
<pre> Challenge
[edit]I'm trying to set up an {{WExample}} template to simplify help pages on MediaWiki syntax and templates documentation. Normally, to get something like
You type | You get |
---|---|
this will be '''bold''' |
this will be bold |
you have to type the code twice, once between <pre></pre> tags, and once without. {{WExample}} should do this automatically. Now it works as long as its parameter doesn't require a transclusion, so for example it cannot be used on itself :
You type | You get | ||||
---|---|---|---|---|---|
{| class="wikitable" ! You type !! You get |- | this will be '''bold''' | this will be '''bold''' |} |
|
The source isn't correct on the leftmost side. Who will be able to solve this will get my eternal gratefulness, and his name engraved in the history of this very useful template ;-)
--Goulu 08:19, 17 May 2010 (UTC)
Parameter name from another parameter in the same template
[edit]I'm struggling to see how {{ppp|p=foo|foo=bar}}
is different from {{#switch:foo|foo=bar}}
. Could someone clarify this for me? Thanks. Smith609 04:25, 20 November 2010 (UTC)
- See Help:Array.--Patrick (talk) 10:33, 20 November 2010 (UTC)
- Very helpful link; thanks for pointing me that way. Smith609 22:30, 27 November 2010 (UTC)
subfunctions
[edit]Do we have a tutorial for calling a subfunction?
Basically, if a field has a certain value, I want it modified with a template, but otherwise to just return the value. (It appears in too many places for it to be economical to modify it within the main template.)
If I'm not being clear, I want to pass the {{{ref}}} field to template/ref. I've tried things like the following:
{{#ifeq: {{{1}}} | keyvalue | <ref>{{Ethnologue| {{{iso3}}} }}</ref> | {{{1}}} }}
The default works fine, but when I use the key value, the 'Ethnologue' template takes the string {{{iso3}}} as its input, rather than the value of the iso3 field. I can't figure out how to pass back the field rather than the string.
On a possibly related note, do we have a description of the difference between {{{1}}}, {{{1|}}}, and {{{1|-}}}? Everything I've found is either more basic or more advanced than that, so I'm stuck in the middle. Kwamikagami 22:08, 16 November 2011 (UTC)
Ah, thanks. That makes sense. But it rather than just returning a 'ref' tag, it also adds a 'ref' field to the info box. And it still returns the internal fields as strings. What I now have:
{{#ifeq: {{{1}}} | keyvalue | {{#tag:ref|{{Ethnologue{{!}}{{{iso3}}}{{!}}{{{name}}} }} |name=ethnologue16}} | {{{1}}} }}
returns the same output, except that it now does it twice: if the key value is input, then the 'if' statement is returned twice, and if anything else is input, the 'if' statement is returned once (as a ref) and the 'then' statement once (as a new field). Kwamikagami 05:08, 17 November 2011 (UTC)
- I modified w:Template:Infobox language/ref to what you might want, but is seems w:Template:Infobox language2 needs some fixes.--Patrick (talk) 07:55, 17 November 2011 (UTC)
- Thanks. That helps get around the tag problem, but it still returns a string rather than a variable. I have no idea why that is happening, or how to correct it. Kwamikagami 08:35, 17 November 2011 (UTC)
- To pass on the value of {{{iso3}}} to an inner template, call the latter with iso3={{{iso3}}}. I made some provisional changes, you can fix the links in the refs, and/or remove one if only one is intended.--Patrick (talk) 07:39, 18 November 2011 (UTC)
- Thanks, Patrick! I never would have figured that out. It works perfectly! Kwamikagami 15:45, 18 November 2011 (UTC)
I came across some bizarre behaviour you might be interested in. I recoded w:Template:Ethnologue with an if statement so that if there is no input, it would generate a generic reference. But if I use #ifexist: {{{1}}}
(with or without a pipe in the {{{1}}}), then it depends on the value of {{{1}}}
, which is unexpected. Here I tested various inputs. They're all fine now (with an #if:
statement), but I have no idea why the behaviour of #ifexist
would depend on the value in the field. Is it buggy, or is that just another feature that I'm clueless about? Kwamikagami 18:51, 18 November 2011 (UTC)
#ifexist:{{{1}}}
checks the existence of the page with as name the value of{{{1}}}
.--Patrick (talk) 23:04, 18 November 2011 (UTC)
- Ah, thanks. I read that too quickly. Amazing what you can figure out if you actually read the instructions! Sorry for wasting your time. Kwamikagami 07:59, 19 November 2011 (UTC)
- The other stuff, that you helped me with, is it covered somewhere? If not, I think it would be useful to add s.t. like it as an example on this page. S.t. like:
- Modifying data with a call to template 'modify', after evaluation by template 'evaluate':
- Call template2 from template1:
{{evaluate|{{{data1}}}|code={{{code}}}|name={{{name}}} }}
- Evaluate {{{data1}}} as "{{{1}}}" on template 'evaluate', and where appropriate, pass data through template 'modify':
{{modify|{{{code}}}|{{{name}}} }}
- For example, by generating a new value based on the other passed variables if it is a certain key value, and returning it as-is if it is not:
{{#ifeq: {{{1}}} | keyvalue | {{modify|{{{code}}}|{{{name}}} }} | {{{1}}} }}
- Evaluate {{{data1}}} as "{{{1}}}" on template 'evaluate', and where appropriate, pass data through template 'modify':
- Kwamikagami 08:31, 19 November 2011 (UTC)
- Help:Template#A_parameter_value_depending_on_parameters explains passing on a parameter value to an inner template, with an example: "The most straightforward way of expressing a parameter value in terms of a parameter is using the same name and making it equal, e.g.
{{Lan is|lr=af|le={{{le}}}}}
in Template:Lan is mr."--Patrick (talk) 10:41, 20 November 2011 (UTC)
- Help:Template#A_parameter_value_depending_on_parameters explains passing on a parameter value to an inner template, with an example: "The most straightforward way of expressing a parameter value in terms of a parameter is using the same name and making it equal, e.g.
the #if function nestable
[edit]I wanted to add that nesting of the #if function is supported but wasn't clear where to add it. If someone has an idea, please go ahead.
The nesting would be in the third parameter. Example: {{#if: test string | value if test string is not empty | {{#if: test string | value if test string is not empty | value if test string is empty (or only white space) }} }}
Nesting can be to at least seven levels, possibly subject to a memory limit.
I assume other functions can be nested but I don't know which ones. I don't know the maximum depth of allowed nesting for the #if function or any other nestable function. If nesting is not subject to a memory limit, that statement should be deleted.
Nick Levinson (talk) 18:08, 24 August 2013 (UTC) (Corrected an opening nowiki tag: 18:13, 24 August 2013 (UTC))
- This is for the general case more or less treated in Help:Expansion#Pipes: "This is applied recursively". For specific info on #if we had Help:ParserFunctions, but this was moved to mw:Help:Extension:ParserFunctions, with "The function may be nested." - Patrick (talk) 23:49, 24 August 2013 (UTC)
- That first link is to a page I would not have understood clearly as meaning that nesting is allowed, so it needs rewording somehow, and the MediaWiki page is that way because I added the text (it wasn't moved), but since this page is separate and is a logical place for finding out how to use the function it should say, but the string "nest" isn't on it. Giving an example and the maximum depth would also help, unless there's a more general location for that, and if there is then that should be cross-referenced. Nick Levinson (talk) 15:54, 27 August 2013 (UTC)
- We have Help:Expansion depth, but it is not always clear to me how the limit works. Since #if is not a template (except in the generalized sense of Help:Expansion) it does not particularly belong on a page about templates. The nesting is a general expansion issue, but examples on mw:Help:Extension:ParserFunctions are fine. - Patrick (talk) 23:30, 27 August 2013 (UTC)
Section: Branching techniques without ParserFunctions
[edit]The section "Help:Advanced templates#Branching techniques without ParserFunctions" is now quite an old section, and with an improved scripting language available in Module: ns, is it time to retire that section? It is not the purpose of a Help: page at meta to represent the history, nor the redundant. — billinghurst sDrewth 23:15, 4 June 2014 (UTC)
Having a Formatting Template Repeatedly Format Content in a Value Defining Template
[edit]I have created two templates, one that defines the format in which I want content to be structured and the second that provides the content itself. So, parameters would be "Title", "Date", and "Blurb"; I do alignment and bold and all that in the Formatting Template, and enter the values to the parameters in the second template. I would like to be able to just continuously use the same parameters, adding more Titles, Dates, and Blurbs to the same second template and have the Formatting Template pick up each section and format it correctly so that when I call both templates a long list shows up multiple titles, dates, and blurb. Any way to do this without creating a new template for each instance?
My problem appears to be this. I have a template which takes 3 arguments, each of which is itself a list of calls to templates: The top level template is called "Assessment"; its arguments are Network Observations; Compute Observations and Physical Observations. The list of template calls contained in each argument to Assessment all include several arguments but they in common, a parameter called "Severity"
What I am trying to do, is set a variable with {{#setvariable:level|Critical}} and then transclude the {{{Network Observations}}} parameter's list of templates; all templates evaluate and refer the to the variable "level" to decide if their Severity matches "level". So far, so good. The I change the value of the variable "level" to be Important and I transclude the same templates a second time. It appears they are NOT re-evaluated at all but are instead re-used as is.
How do you clue the template parse in that I want these evaluations to be volatile, i.e. that they are dependent on a global variable of which the caching mechanism is not otherwise aware?
First use of template within page?
[edit]Is there a way to test for the first use of a particular template in a page? Use case would be to provide a longer alt text on the first use of a symbol template on a page, but for subsequent uses of the same symbol template to use just the name of the symbol as the alt text. Thisisnotatest (talk) 22:14, 20 September 2015 (UTC)
Where can I go for coding help?
[edit]I'm having trouble coding a template for a wiki that uses wikimedia-based markup. All the people I usually ask for help either cannot solve my problem, or are too busy to answer. Where is the appropriate place to go to ask for help with my specific problem?
Thanks, Iustinus (talk) 19:24, 18 October 2015 (UTC)
Efficiency advice
[edit]I'm intending to create a template for easy citation of a stock set of sources, such that
{{grammar source|CMS16|p=37|chapter=Capitalization}}
or
{{grammar source|NHR2|pp=27–32|chapter=Full stop}}
will auto-generate a w:en:Template:Cite book citation with all the stock citation information (author/editors, publisher, publisher location, date, URL, ISBN, etc.) pre-filled, and do this for a long list of grammar and style sources that we need to frequently cite in en.wp articles on English language grammar and usage, like The Chicago Manual of Style 16th ed, or New Hart's Rules 2nd ed.., for these two examples.
What's the most efficient way to go about this, without having to resort to a Lua/Scribunto module? I'm not certain that the most obvious answer to an everyday template editor is the correct one, given the variety of technical considerations outlined on this page, some of which aren't easy to parse for someone not steeped in MediaWiki's internals.
I'm thinking that it needs a switch [perhaps in a subtemplate] that then calls a[nother] subtemplate to to populate the cite tags. Ideally, the list of sources and their details, given in a set order of parameter values, would be a separate transclude for easy expansion with low risk to accidentally doing something to the surrounding code.
In a very similar vein, I want to create a template called {{WP}} that will take any value like "WP:NPOV", check a list of known shortcuts, and wrap <abbr>...</abbr>
around it with w:en:Template:Abbr, with the expansion of the shortcut as the tooltip text ("Wikipedia:Neutral point of view"), and also be able to check a list of common #-anchor targets in major policy pages, and add those, too (e.g. if someone gives {{WP|NOT|SOAPBOX}})
. The entire output would be styled with w:en:Template:Smallcaps2 to reduce the shouting effect of all-caps shortcuts. I would see about having a bot maintain the list of shortcuts, by tracking where every "WP:<string of uppercase characters>" redirect points to, so it would again be useful if this list were in a transcluded file.
— SMcCandlish ☺ ☏ ¢ ≽ʌⱷ҅ᴥⱷʌ≼ 19:40, 19 February 2016 (UTC)
- It's been suggested at w:en:Help talk:Template that the w:en:Template:Flag template (the implementation of which is laid out at en:w:Wikipedia:WikiProject Flag Template#Implementation). This is the route I'll follow, absent some reason not to. — SMcCandlish ☺ ☏ ¢ ≽ʌⱷ҅ᴥⱷʌ≼ 19:44, 20 February 2016 (UTC)
How to translate
[edit]Can I translate this page to my native language? how to? Mohamadhzanhari (talk) 09:39, 8 August 2017 (UTC)
Redlink in example at end of intro
[edit]The intro ends, "See, e.g., Template talk:Lop." This should be changed to a better and existing example. Look how many times it's been recreated and deleted!
- 02:26, 17 July 2017 StevenJ81 (talk | contribs) deleted page Template talk:Lop (G1: Test, please use the sandbox)
- 19:56, 24 February 2017 Tegel (talk | contribs) deleted page Template talk:Lop (G1: Test, please use the sandbox)
- 19:54, 24 February 2017 Tegel (talk | contribs) deleted page Template talk:Lop (G1: Test, please use the sandbox)
- 00:09, 9 February 2017 Matiia (talk | contribs) deleted page Template talk:Lop (G1: No meaningful content or history)
- 18:17, 23 April 2012 Tegel (talk | contribs) deleted page Template talk:Lop (G1: Test, please use the sandbox)
- 13:16, 17 March 2011 Pmlineditor (talk | contribs) deleted page Template talk:Lop (Talk page of deleted content)
Sorry all I can do is point this out! Thanks in advance, Geekdiva (talk) 20:21, 10 September 2017 (UTC)
Get Practical
[edit]To be honest, all these mind-game, arcane codes that are included into pages like this are nearly worthless for the average contributor. I work on Fandom pages, and simply wanted a basic way to set up variables in a template without having to implement complex code, alter the css, or adding any other support pages. The examples included in pages like this are impractical and useless when it comes to mass application. Truly, half these things are often wrong anyway. I have code in pages that violates all the rules, yet works, and have tried other code, even copied directly, that works not at all. I absolutely think that somebody needs to review wiki markup for consistency, and create a guide that uses practical applications that people besides the most adamant of nerds (I am an admitted geek) will understand. Thank you (if you plan to do something about this^^). 2019-07-30T00:09:12 2.135.67.148
"Variable variable names"
[edit]The page reads as if it's playing a pun on the reader. There are many synonyms for the ambiguous term: "changeable", "mutable", "varying", etc. The current version is unnecessarily complicated. Fgnievinski (talk) 23:07, 31 August 2023 (UTC)
- And "changeable" is not it, and should only be changed on consensus, not a personal opinion. The whole page needs a rewrite, as it is structured around English language words with similar meaning, and that means a new approach is required. We also need to get rid of the old coding methodology. OR we say that the page belongs at mediawikiwiki and look to build the replacement there. Really it is not a metawiki help page, and we should redirect to where it should be. — billinghurst sDrewth 21:37, 13 December 2023 (UTC)
- I have moved this page to MediaWiki.org as part of mw:Project:MediaWiki documentation on Meta-Wiki. I made some minor cleanups, but did not do a fundamental rewrite. * Pppery * it has begun 23:42, 28 June 2024 (UTC)