Help talk:Template: Difference between revisions

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
Reverted good faith edits by Kwamikagami (talk); Rv unclear addition; on the wrong page, I think. (TW)
Line 386: Line 386:
: Caching issue. I opened the template, made no edits, then saved it, and now it appears in the category. I find this is necessary if you add the category to the doc page and don't want to wait for the server to recache the page. Thanks! [[User:Plastikspork|Plastikspork]] [[User talk:Plastikspork|<sub style="font-size: 60%">―Œ</sub><sup style="margin-left:-3ex">(talk)</sup>]] 20:44, 2 April 2011 (UTC)
: Caching issue. I opened the template, made no edits, then saved it, and now it appears in the category. I find this is necessary if you add the category to the doc page and don't want to wait for the server to recache the page. Thanks! [[User:Plastikspork|Plastikspork]] [[User talk:Plastikspork|<sub style="font-size: 60%">―Œ</sub><sup style="margin-left:-3ex">(talk)</sup>]] 20:44, 2 April 2011 (UTC)
::Thanks very much. I was asking myself what on ''earth'' have I ''done'' and scratching my head. [[User:Dmcq|Dmcq]] ([[User talk:Dmcq|talk]]) 21:38, 2 April 2011 (UTC)
::Thanks very much. I was asking myself what on ''earth'' have I ''done'' and scratching my head. [[User:Dmcq|Dmcq]] ([[User talk:Dmcq|talk]]) 21:38, 2 April 2011 (UTC)

{{respell|IL|i|NOY|'}}

Revision as of 12:32, 11 May 2011

WikiProject iconWikipedia Help NA‑class
WikiProject iconThis page is within the scope of the Wikipedia Help Project, a collaborative effort to improve Wikipedia's help documentation for readers and contributors. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks. To browse help related resources see the Help Menu or Help Directory. Or ask for help on your talk page and a volunteer will visit you there.
NAThis page does not require a rating on the project's quality scale.

Problem with if scripts

I'm a user on the Danish version of Uncyclopedia ([1]). I've been trying to get this template to work in a few days, but somehow it just won't do as I want. It's meant to create a table with two rows and a picture to the right. In the upper row, there is going to be security marks for a product, while the lower row is going to have up to four columns with product descriptions.

The problem lies in the upper row, as the lower row already works. Se the result here: [2]

Here's the script (most of it is in English; only security mark descriptions are in Danish). You should look at the script of this page, as Wiki puts everything into one line here:

{| border="1" class="metadata" style="width:100%; background-color:rgb(255,102,0)" | {{ #ifeq: {{{picton|0}}} | 0 | colspan="2" | }} style="align:center;" | {{ #if: {{{1mark|}}} | {| | [[billede:{{ #switch: {{{1mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{1mark|}}}.gif | #default = {{{1mark|}}} }}]] |- ! <big>{{{1head|}}}</big> |- | {{{1text|}}} |} | }} {{ #if: {{{2mark}}} | {| | [[billede:{{ #switch: {{{2mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{2mark|}}}.gif | #default = {{{2mark|}}} }}]] |- ! <big>{{{2head|}}}</big> |- | {{{2text|}}} |} | }} {{ #if: {{{3mark}}} | {| | [[billede:{{ #switch: {{{3mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{3mark|}}}.gif | #default = {{{3mark|}}} }}]] |- ! <big>{{{3head|}}}</big> |- | {{{3text|}}} |} | }} {{ #if: {{{4mark}}} | {| | [[billede:{{ #switch: {{{4mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{4mark|}}}.gif | #default = {{{4mark|}}} }}]] |- ! <big>{{{4head|}}}</big> |- | {{{4text|}}} |} | }} {{ #if: {{{5mark}}} | {| | [[billede:{{ #switch: {{{5mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{5mark|}}}.gif | #default = {{{5mark|}}} }}]] |- ! <big>{{{5head|}}}</big> |- | {{{5text|}}} |} | }} {{ #if: {{{6mark}}} | {| | [[billede:{{ #switch: {{{6mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{6mark|}}}.gif | #default = {{{6mark|}}} }}]] |- ! <big>{{{6head|}}}</big> |- | {{{6text|}}} |} | }} {{ #if: {{{7mark}}} | {| | [[billede:{{ #switch: {{{7mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{7mark|}}}.gif | #default = {{{7mark|}}} }}]] |- ! <big>{{{7head|}}}</big> |- | {{{7text|}}} |} | }} {{ #if: {{{8mark}}} | {| | [[billede:{{ #switch: {{{8mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{8mark|}}}.gif | #default = {{{8mark|}}} }}]] |- ! <big>{{{8head|}}}</big> |- | {{{8text|}}} |}|}} | {{ #ifeq: {{{picton|0}}} | 1 | rowspan="2" width="{{{pictwidth|}}}" }} | {{ #ifeq: {{{picton|0}}} | 1 | [[billede:{{{pictaddr|}}}|{{{pictwidth|}}}]] }} |- | {{ #ifeq: {{{picton|0}}} | 0 | colspan="2" }} | {{ #ifexpr: {{{cols|1}}} >= 1 |<div style="width: {{ #expr: 100 /{{{cols|1}}} }}%; float: left;">{{{1col|}}}</div>}} {{ #ifexpr: {{{cols|1}}} >= 2 |<div style="width: {{ #expr: 100 /{{{cols|1}}} }}%; float: left;">{{{2col|}}}</div>}} {{ #ifexpr: {{{cols|1}}} >= 3 |<div style="width: {{ #expr: 100 /{{{cols|1}}} }}%; float: left;">{{{3col|}}}</div>}} {{ #ifexpr: {{{cols|1}}} >= 4 |<div style="width: {{ #expr: 100 /{{{cols|1}}} }}%; float: left;">{{{4col|}}}</div>}} |}

Template naming conventions

I've suggested standardizing template naming, at Wikipedia talk:Template namespace#Template naming conventions. If you're frustrated with typing template names and constantly guessing at the right capitalization and spacing, please chime in. Michael Z. 2009-01-10 17:46 z

string handling

Hello, I am trying to create a template that would transform

painter, sculptor, musician

into

{{some template |occupation1=painter |occupation2=sculptor

|occupation3=musician}}

I manage to get the first word using {{trunc}} but I can't find any similar template for words to the right of the coma ({{str right}} produces errors. Can anyone help ?

(note:I want to use the template on Commons but tried it here because we have no string manipulation templates out there).

--Superzoulou (talk) 17:23, 18 January 2011 (UTC)[reply]

These string processing templates are very fragile, and I am not surprised they are giving you problems. They are basically almost all based on expensive hacks which overload the "padleft" parserfunction. You would be better off passing them all into one field, and having a bot split them into subfields. With that said, this should be possible in some cases, I just don't think you will be able to do it reliably. For example, if the input string is too long. Plastikspork ―Œ(talk) 23:42, 19 January 2011 (UTC)[reply]
Ok thanks, I hope we get something better some day--Superzoulou (talk) 20:32, 20 January 2011 (UTC)[reply]

I would like to add a feature to Template:Official website It should be able to display:

... by allowing someone to put in an extra field for a mobile site Such as "|mobile=http://m.cnn.com WhisperToMe (talk) 21:31, 19 January 2011 (UTC)[reply]

Help with selected transclusion

Hi. I have recently created {{TAYG episode}} which at this stage is a mask for {{Episode list}}. I have unsuccessfully tried to add code to only transclude some of the parameters (i.e. some of the columns in the resultant table). I was trying to utilise the code in {{Episode list/sublist}} but I have failed any attempt. I'd like to only transclude Episode, Airdate, B, X, Y and Notes column (i.e. leaving out EndGame, Winner, Viewers, Ratings). I have a sandbox which has some of the original data in it here with the page I'd like to transclude some of the cells onto here. Thanks to anyone who can help. Themeparkgc  Talk  02:35, 26 January 2011 (UTC)[reply]

So you want it to have a total of six columns (Episode, Airdate, B, X, Y and Notes) in that order? Plastikspork ―Œ(talk) 03:07, 26 January 2011 (UTC)[reply]
Only when it is transcluded, yes. Themeparkgc  Talk  03:22, 26 January 2011 (UTC)[reply]
I see. There are basically two ways that I know of to accomplish this. The first way would be have the template take an extra parameter, like say |sublist=, which when set, would hide the extra columns. Then on the main page, with the full list, you would use either <noinclude>...</noinclude> or <includeonly>...</includeonly> to set the value for either the main page, or the transcluding page, depending on the logic. The second way would be to exploit the Template value for the main page and the subpage. This would allow the template to determine if it is being used on the main page or on the trancluding page. Is there a particular pattern for the names of the main pages or the subpages? How many pages are going to be using this template? Could the list of main pages be provided in a list that could be passed to a "switch" statement? The second method hides more of the logic from the average editor, and is a bit more elegant, but it doesn't scale as well in terms of usage with lots of pages, and requires some knowledge of the page naming structure. Plastikspork ―Œ(talk) 05:25, 26 January 2011 (UTC)[reply]
The idea is to only have to update the season page with the summary page updating automatically to show only Episode, Airdate, B, X, Y and Notes, stripping out the other columns in the process. I have tried to incorporate |MainList= or |1= to test to see whether it matches {{PAGENAME}} which is the summary page. Although the same method works perfectly for {{Episode list/sublist}} it doesn't seem to work here. This template would probably be used around 20-30 times on a single page (once per episode for the season). The whole table is wrapped in <onlyinclude>...</onlyinclude> so the lead, infobox and references sections are not transcluded. The page would then be transcluded with {{:List of Talkin' 'Bout Your Generation episodes (series 2)}} onto the summary page. I think the way used in {{Episode list/sublist}} is the simplest, I just can't seem to get it to work. Themeparkgc  Talk  07:45, 26 January 2011 (UTC)[reply]

Very strange. I can get it to work in my userspace but not in the article space. I have the original full data here, with the transcluded version here. Working perfectly. When I tried to incorporate the full data on the article namespace here that worked fine, but when I transcluded it here, it did not get rid of the unwanted columns. Is it possibly the two apostrophes (" ' ") in the articles' titles conflicting with the script somehow? Themeparkgc  Talk  03:48, 29 January 2011 (UTC)[reply]

Yes, that's the problem. Since this is only going to be used on one page, you might as well hardcode the fix. I will do it in a second. The other option would be to put what I am going to paste in there in the episode articles, which would be messy, but would also work. Plastikspork ―Œ(talk) 04:01, 29 January 2011 (UTC)[reply]
Thank you very much for getting it to work. Themeparkgc  Talk  04:39, 29 January 2011 (UTC)[reply]

Why is the template in the bottom of the page?

I have just recently worked on a template for a article expansion, located here User:AJona1992/Sandbox11. What can I do so the template can be at the section it should be in? AJona1992 (talk) 21:16, 26 January 2011 (UTC)[reply]

It wasn't a template issue at all, you hadn't closed the table in the section U.S. television ratings. Unclosed tables are always moved to the last section, and they then suck in the entire content of that section. I have fixed it. --Redrose64 (talk) 21:23, 26 January 2011 (UTC)[reply]

Pass-Through Parameters (Redux)

I asked this question once before, had some responses asking me to clarify, and then after clarifying: No one responded ever again. So I'm going to try again with a simpler, thoroughly-described example.

Say I have 5 templates. Each template consists of 5 elements. These elements are all different for each template except for 1; I.e. the 5 templates share only 1 common element.

If the common element is a static object of some kind (an image, a decorative box, a standard piece of text, etc.) the obvious solution is to make a template out of that 1 common element, and then transclude it in each of the 5 templates. In each of the 5 templates, you would do this:

{{Common-parameter}}
^^ In English: All I'm doing is trancluding the {{Common-parameter}} template. Simple.

Voila! redundant work eliminated; you don't have to implement that element in 5 different places, only in 1 place.

Now, if that 1 common element is instead a named parameter whose value is displayed in the same way in all 5 templates, you would make a template out of that 1 named parameter and its associated display code, and then transclude it in each of the 5 templates. In each of the 5 templates, you would do this:

{{Common-parameter | parameter1 = {{{parameter1}}} }}
^^ In English: I'm transcluding the {{Common-parameter}} template, and passing its {{{parameter1}}} the value in the current template's {{{parameter1}}}.

Unfortunately, you have to give each of your 5 templates a {{{parameter1}}} and then pass its value through to {{Common-parameter}}'s {{{parameter1}}}, which is a little redundant and features a small amount of repeated code; but at least all of the display code for that element is housed in the {{Common-parameter}} template, so that part need not be repeated. So you saved some redundant work.

Now, if that 1 common element is a conditional named parameter, and looks something like this:

{{#if: {{{parameter1|}}} | {{{parameter1}}} }}
^^ In English: If {{{parameter1}}} is actually filled in with a value, display it, otherwise don't display it.

you would make a template out of that 1 conditional named parameter and its associated display code, and then transclude it in each of the 5 templates. In each of the 5 templates, you would do this:

{{Common-parameter | parameter1 = {{#if: {{{parameter1|}}} | {{{parameter1}}} }} }}
^^ In English: If {{{parameter1}}} is actually filled in with a value, pass it to {{Common-parameter}}'s {{{parameter1}}}, otherwise don't do anything with it. The {{Common-parameter}} template then does the same thing; if its {{{parameter1}}} is actually filled in with a value, display it, otherwise don't display it.

Ouch. So not only do you have to implement the conditional in the {{Common-parameter}} template, you have to re-implement that conditional in all of the 5 templates that use it. That's a lot of redundant code. Not only do you have to give each of your 5 templates a {{{parameter1}}} and then pass its value through to {{Common-parameter}}'s {{{parameter1}}}, you also have to completely re-implement the conditional statement in every location. What the hell!

Basically, it comes down to this: If you have a conditional parameter that is repeated in multiple templates, you either have to just implement it in each of those multiple templates and deal with the redundant code, or you have to implement it in its own template, transclude that template in your multiple templates, and then re-implement the conditional in each of those templates anyway, thus defeating the purpose of putting it in its own template to reduce redundant code. This may sound like somewhat of a non-issue as presented, and with such a comparatively small example, but what if the {{Common-parameter}} template could also stand alone? I.e. {{Common-parameter}} is useful when displayed directly in an article and is also used as a small part of the display of other, larger display templates. Or imagine my example with 100 templates with 100 conditional parameters each, 50 of which are common to all 100 templates; it starts to get out of hand real quick.

So: Is there some way to do this that doesn't run into the problems I've outlined? Is there some basic, simple principle to templates that negates the issues I described? Or is there just no way around this whatsoever?
--Cogniac (talk) 21:03, 3 February 2011 (UTC)[reply]

Is this going to be for Wikipedia - or is it for UOGuide? I think that could have been why the users did not respond the last time. I would help but I think it is beyond me. I'm a bit confused with what you're wanting to do.
Themeparkgc  Talk  23:32, 3 February 2011 (UTC)[reply]
When I originally asked the question back in April 2010 my only goal was to figure out how to do this for a specific template structure on UOGuide. Since then I've realized that the problem is relevant to all wikis, including and especially Wikipedia due to the overwhelming number of templates in use here, some subset of which would be improved if this were possible. In all actuality, I should probably be asking this question at http://www.mediawiki.org/wiki/Help_talk:Templates, but a lot fewer people view that page, and it seems as though there are volunteers here at Wikipedia that either a.) possess an extensive knowledge on wiki-coding and coding for wikis that rivals anyone at MediaWiki.org just due to how much work they put in and how much code they review here at Wikipedia or b.) are literally the exact same volunteers that would be answering my question at MediaWiki.org.
--Cogniac (talk) 21:13, 4 February 2011 (UTC)[reply]

I think the basic answer is no, you can't pass through parameters implicitly in the way we would sometimes want to (i.e. there's no equivalent of global variables in template logic). Though your code can be simplified - writing

  • {{#if: {{{parameter1|}}} | {{{parameter1}}} }}

is no different from writing just

  • {{{parameter1|}}}

(the meaning of the first is "the value of parameter1 if the parameter exists and is non-empty, else the empty string", and the meaning of the second is "the value of parameter1 if the parameter exists, else the empty string", which is exactly equivalent. As far as I can tell, anyway.)
--Kotniski (talk) 13:31, 4 February 2011 (UTC)[reply]

Re: The code simplification - That works, but only with situations like my example; I.e. a parameter that has no accompanying display code. In the following example, you'd be adding a row, and a cell in that row, to a table if {{{parameter1}}} has a value:
{{#if: {{{parameter1|}}}
| {{!}}-
  {{!}} style="background-color:#000000; color:#FFFFFF;" {{!}} {{{parameter1}}}
}}
Your way looks like this:
|-
| style="background-color:#000000; color:#FFFFFF;" | {{{parameter1|}}}
which would result in the row+cell being introduced into the table whether that parameter is filled in or not.
--Cogniac (talk) 21:13, 4 February 2011 (UTC)[reply]

I'm not really understanding what you're asking - a practical example would be useful. are you talking about 5 sequentially nested templates, and you're trying to pass a conditional parameter down through the chain?
--Ludwigs2 17:12, 4 February 2011 (UTC)[reply]

My example was not referring to 5 sequentially nested templates, but rather 5 completely separate templates. However, I will attempt to describe a simple example using sequential nesting: Imagine you are making 2 templates for a particular type of object on Wikipedia.
  • The first template is used to display a labeled list of basic information about an object, possibly for use as a quick reference on related pages, or on list pages. Most, if not all, of the parameters in this template are conditional. Each instance of the object type may have a different subset of the information list. To use it, you fill in the parameters that correspond to what the object instance actually has, and you ignore the other parameters. (Crude Example: Say the object type is "Tool." A Hammer has a handle length, Sandpaper does not, so when using this template to describe Sandpaper, you wouldn't fill in the "|handleLength=" parameter.)
  • The second template would be the Infobox for use on the actual pages of that type of object. This template would be comprised of all the information contained in the first template, plus a picture of the object, all housed in a visually-pleasing box of some sort.
The obvious response would be to transclude the first template into the second template, and make it so filling in parameters in the second template would just pass them through to the first template. But since the parameters in the first template are conditional, you would have to write all of the conditional code over again in the second template. This means that not only would you not be eliminating redundant code, you would be making it twice as bad!
--Cogniac (talk) 21:13, 4 February 2011 (UTC)[reply]
Then why not incorporate the image (and any other parts of the second template) into the first template and repeat them. It seems like in the end you'd have less repeated code.
Themeparkgc  Talk  21:39, 4 February 2011 (UTC)[reply]
Because the second template is an Infobox. Infoboxes go in the top-right corners of articles, not all over the place in list pages. When's the last time you saw a page that was just a list of Infoboxes? That's why the first template was just a list of the salient information: for use on pages where putting the whole Infobox would be stupid. But this whole point is moot as I'm about to post a bit of a mea culpa about this whole topic.
--Cogniac (talk) 22:40, 4 February 2011 (UTC)[reply]

So, I just had a bit of an epiphany that was triggered by Kotniski's post. I made a {{Test1}} template like this:

{|
{{#if: {{{parameter1|}}} | {{!}} style="background-color:#000000; color:#FFFFFF;" {{!}} {{{parameter1}}} }}
|-
{{#if: {{{parameter2|}}} | {{!}} style="background-color:#FF0000; color:#FFFFFF;" {{!}} {{{parameter2}}} }}
|-
{{#if: {{{parameter3|}}} | {{!}} style="background-color:#00FF00; color:#FFFFFF;" {{!}} {{{parameter3}}} }}
|-
{{#if: {{{parameter4|}}} | {{!}} style="background-color:#0000FF; color:#FFFFFF;" {{!}} {{{parameter4}}} }}
|-
{{#if: {{{parameter5|}}} | {{!}} style="background-color:#93E0F0; color:#FFFFFF;" {{!}} {{{parameter5}}} }}
|}

It makes a table, and each parameter corresponds to a color-coded cell in the table. If you don't fill in one of the parameters, the corresponding cell isn't displayed. If you don't fill any of them, the whole table isn't displayed.

Then I made a {{Test2}} template like this:

{|
! Test
|-
| {{Test1
|parameter1={{{parameter1|}}}
|parameter2={{{parameter2|}}}
|parameter3={{{parameter3|}}}
|parameter4={{{parameter4|}}}
|parameter5={{{parameter5|}}}
}}
|}

It's another table, with a header and a cell in the next row that houses within it {{Test1}}.

As it turns out, that totally works for passing through conditional parameters without having to re-implement the conditional code. The problem was that I just wasn't thinking about it in the right conceptual context. So in my original post above, where I put

{{Common-parameter | parameter1 = {{#if: {{{parameter1|}}} | {{{parameter1}}} }} }}

I could have just put

{{Common-parameter | parameter1 = {{{parameter1|}}} }}

and gotten the same effect.

So I guess the only thing I could complain about now is the fact that there's no way to access the parameters of {{Test1}} through {{Test2}} without creating corresponding parameters in {{Test2}} like I just did above; I.e. you can't implement something similar to Inheritance (Java/C#/C++ style). And I'm not really sure that's even something that would be a good idea to have.
--Cogniac (talk) 22:40, 4 February 2011 (UTC)[reply]

Yes, you're not the first person to wonder about this; I think it would be found generally quite useful to have such a thing. Although the template "programming language" is bad in so many ways that I think the developers have just about given up on it - it might be replaced one day with proper scripting, but meanwhile the devs have made it their mission not to improve the current setup (bizarre but true), denying us the use of even obvious improvements like string functions, so there isn't much point in asking them to fix minor inconveniences like the lack of inheritance.--Kotniski (talk) 09:09, 5 February 2011 (UTC)[reply]

Includeonly

For meta-templates, is it possible to includeonly an includeonly tag? McLerristarr | Mclay1 06:24, 7 February 2011 (UTC)[reply]

I don't think you can. I tried:
<includeonly>
   Line to be included on all transclusions.
   <includeonly>
      Line to be included on all transclusions except the first.
   </includeonly>
</includeonly>
but it didn't work. It seems to ignore the second <includeonly> and display the second </includeonly> as text. Is that what you were asking? Themeparkgc  Talk  10:00, 7 February 2011 (UTC)[reply]
Pretty much, yes. Thanks for trying. Templates are quite good now but I guess some things are just impossible. McLerristarr | Mclay1 14:43, 7 February 2011 (UTC)[reply]
Perhaps you can do it somehow, but not like that (the parser will assume that the first closing tag goes with the first opening one - it won't handle nesting of the same tag). Try breaking up the syntax by writing <noinclude></noinclude> somewhere in the middle of the includeonly tag(s) - that sort of thing quite often works.--Kotniski (talk) 15:41, 7 February 2011 (UTC)[reply]
Why does this not work? <includeonly><</includeonly>includeonly>abcdefg<includeonly><</includeonly>/includeonly> The includeonly tags end up appearing as normal text rather than working. McLerristarr | Mclay1 17:02, 24 February 2011 (UTC)[reply]
The same thing happens when I do this: <include<noinclude></noinclude>only>hijklmnop</include<noinclude></noinclude>only> Breaking the includeonly tag stops it from working and makes it appear as normal text. There doesn't seem to be any way of making a template transclude an includeonly tag on a page. McLerristarr | Mclay1 17:08, 24 February 2011 (UTC)[reply]
Yes, on reflection, it probably isn't possible. The parser probably does things in a different order than it would need to for this to work. (I.e. if your page says {{A}} and Template:A contains {{B}}, then it won't transclude B onto (a working version of) A and then transclude that onto your page; it will just transclude A (i.e. the text {{B}}) onto your page, and then process that text further by transcluding B onto your page. B only really undergoes one transclusion operation. I suppose it would work if you subst:'ed B on Template:A, but that might not suit your application.) --Kotniski (talk) 17:16, 24 February 2011 (UTC)[reply]
No, I don't want to substitute. Anyway, thank you for the help. I'll just have to find a way around it. McLerristarr | Mclay1 18:00, 24 February 2011 (UTC)[reply]

Can't edit a template

This is odd. So I was on ASVEL Basket and noticed the roster was out of date. I was going to edit it, but then I clicked the little e it went to a page that said there isn't a template named that. The template is here Template:ASVEL_Lyon-Villeurbanne but when I edit it, it says it's not there. So where is it? --AW (talk) 20:31, 24 March 2011 (UTC)[reply]

Ok, so I see where it is to edit it, but the little e goes to the wrong page, Template:ASVEL_Lyon-Villeurbanne_roster, which doesn't exist. How do I change that? --AW (talk) 20:31, 24 March 2011 (UTC)[reply]
Obviously not by creating a redirect, that didn't work. Help? --AW (talk) 20:34, 24 March 2011 (UTC)[reply]
You are correct in that it was linking via Template:ASVEL Lyon-Villeurbanne roster, but when creating the redirect, you forgot the crucial word "Template:", as in
#REDIRECT [[Template:ASVEL Lyon-Villeurbanne]]
It seems to be something within the {{Euroleague roster header}} template that is causing it to set up the v-d-e links to point to Template:ASVEL Lyon-Villeurbanne roster instead of to Template:ASVEL Lyon-Villeurbanne. I need to look deeper. --Redrose64 (talk) 21:06, 24 March 2011 (UTC)[reply]
Yep. It's expecting the template name to be "Template:Xxxx roster", where "Xxxx" is the team name displayed in the top bar. This means that there will be similar problems affecting most of these templates, at least the ones which don't end in "roster" anyway. So, Template:Menorca Bàsquet exhibits the same problem, whereas Template:Panathinaikos BC roster is fine. --Redrose64 (talk) 21:16, 24 March 2011 (UTC)[reply]

parameters in templates passed into templates tested and failing

I have a problem with testing parameters being used in one template which work as I expect when the template is called directly. But if the same template is called from another one the testing of the parameters does not work the same way. I know what is failing but I can not find anything in the help pages on how to fix it.

{{TB|pam1=FU|pam2=BAR}} The test inside the template works as expected but {{TA|pam1=FU|pam2=BAR

{{TB|pam1=FU|pam2=BAR}}

}} the test within TB fails. Is this the best place to discuss this problem or is the a better one? -- PBS (talk) 23:42, 26 March 2011 (UTC)[reply]

Can you explain it with real templates? I presume you don't mean the actual templates {{TA}} and {{TB}}?--Kotniski (talk) 10:31, 27 March 2011 (UTC)[reply]
Na I used those initial as short for "TemplateA" "TemplateB". The best thing I can do is make two simple templates which display this problem. At the moment the actual templates they are quite complicated so its wood for trees. I set up a simple example some time in the next day or so, and then post it here. First I wanted to check that this was the best place to discuss it. --PBS (talk) 00:11, 28 March 2011 (UTC)[reply]

OK in my own name space I have set up two templates. here is the first template:

Print in Test:<!--
-->{{#ifeq:{{{wikisource|{{{wstitle|}}} }}}|<!--eq to empty
-->|<!--then-->Print Hello 1
|<!--else-->Print Hello 2
}}

The second template is:

{{test
|wikisource= {{{wikisource|}}}
|title= {{{title|}}}
|wstitle= {{{wstitle|}}}
}}

Here are three examples calling what I have described above as "test" directly:

  • {{User:PBS/test|title=FU}}
  • {{User:PBS/test|wstitle=FUws}}
  • {{User:PBS/test|wikisource=FUsource}}

Here are are the same parameters passed into a second template (test2) that calls the "test" passing in three parameters:

  • {{User:PBS/test2|title=BAR}}
  • {{User:PBS/test2|wstitle=BARws}}
  • {{User:PBS/test2|wikisource=BARsource}}

The problem lies in the handling of FUws "Test:Print Hello 2" and BARws "Test:Print Hello 1". Until I ran across this problem I would have expected the two tests would be the same. If I alter the internal test code from {{{wikisource|{{{wstitle|}}} }}} to {{{wstitle|{{{wikisource|}}} }}} then as I would expect given the first failure is wikisource that then displays two different results.

I hope that is enough detail. -- PBS (talk) 01:05, 28 March 2011 (UTC)[reply]

Got it. The thing is that whilst you have filled in |wstitle= in both cases, the parameter |wikisource= is treated differently depending upon whether it is present or absent. Note that "present" does not mean "has been given a value". The construct {{{wikisource|{{{wstitle|}}} means "if wikisource is present (regardless of whether it has a value or not), use {{{wikisource}}}; if wikisource is entirely absent, use {{{wstitle}}}".
If you intend a blank parameter to be treated as if it were completely absent, you need to amend the second line of user:Philip Baird Shearer/test, thus:
-->{{#ifeq:{{#if: {{{wikisource|}}}|{{{wikisource}}}|{{{wstitle|}}} }}|<!--eq to empty
--Redrose64 (talk) 17:27, 28 March 2011 (UTC)[reply]
Or to explain it slightly differently, the second template is always passing some value of wikisource to the {{user:Philip Baird Shearer/test}} template, even if it's only the empty string, so the test template will (then) never be interested in the value of wstitle.--Kotniski (talk) 17:43, 28 March 2011 (UTC)[reply]
Thanks to both of you. OK although I understand your explanations, but I am clearly missing one level of intellectual understanding as I had assumed that functions called from within functions would handle parameters in the same way as they would when called from a page and that was my understanding from reading #Pass-Through Parameters (Redux) above ie there was no concept of a global variable. Is there a help page that discusses this concept? If not I think it would be helpful if a section was added somewhere.
An immediate problem that I have is that for the test I used a simple two parameter test, but what I want to test is five parameters long:
{{{1|{{{wstitle|{{{wikisource|{{{article|{{{title|}}}...
is a very large nested test the best way to do this, or is there a better/clearer method? -- PBS (talk) 21:32, 28 March 2011 (UTC)[reply]
It's not a case of different behaviour of templates when used directly in articles vs. when used in other templates, but different behaviour depending upon whether unneeded parameters are blank or omitted. Consider the following:
{{User:Redrose64/test|wstitle=FUws}}
{{User:Redrose64/test|wstitle=FUws|wikisource=}}
The only difference between the two is that the second one specifies |wikisource= but leaves it blank. The resultant output is:
Print in Test:Print Hello 2
Print in Test:Print Hello 1
These are clearly different (the template {{User:Redrose64/test}} is a straight copy of your test template prior to the 18:16 amendment).
There is indeed no concept of a global variable; neither are there local variables. All we have are system variables, which may be read but not written to: these include such things as {{PAGENAME}}.
I did suggest to Kotniski (talk · contribs) (see here) that this absent/blank non-equivalence be mentioned, but I can't find it. --Redrose64 (talk) 21:57, 28 March 2011 (UTC)[reply]
In the middle of the "Full syntax..." section it says The value of a parameter can be the empty string (pipe or equals sign followed immediately by the next pipe or the closing braces). This is different from leaving the parameter undefined (although templates are often coded so as to behave the same in both cases). Does this need to be made more prominent and/or clearer and/or repeated in other parameter-related sections?--Kotniski (talk) 09:08, 29 March 2011 (UTC)[reply]
OK got it now! By modifying the second template (test2) to :
{{test
|title= {{{title|}}}
|wstitle= {{{wstitle|{{{wikisource|}}} }}}
}}
The problem goes away! because wikisource is no longer passed into the first template (test) so it is no longer set to blank. I see now that my focus was on the wrong template.-- PBS (talk) 00:21, 29 March 2011 (UTC)[reply]

Template not appearing in category

I've looked at this but I just can't see why it isn't working - could someone have a quick look at Template:Mabs please and tell me why it doesn't appear in Category:Mathematical formatting templates. Thanks. Dmcq (talk) 12:04, 2 April 2011 (UTC)[reply]

Caching issue. I opened the template, made no edits, then saved it, and now it appears in the category. I find this is necessary if you add the category to the doc page and don't want to wait for the server to recache the page. Thanks! Plastikspork ―Œ(talk) 20:44, 2 April 2011 (UTC)[reply]
Thanks very much. I was asking myself what on earth have I done and scratching my head. Dmcq (talk) 21:38, 2 April 2011 (UTC)[reply]