Help talk:Substitution

From Wikipedia, the free encyclopedia

Why substitute?

I don't understand this help page and I doubt that anyone else without a lot of experience in Wiki coding would either. Can someone explain the reasons for substitution, other than the expanded text, to me in plain English? Also, as a general comment, I have to say I find filling in the gaps in the expanded text difficult, laborious and not at all user-friendly. Thanks.Grant65 | Talk 07:48, 11 January 2007 (UTC)

One could add {{pedagogic}} --Nopetro 17:08, 16 June 2007 (UTC)
See "Benefits of substitution" on Wikipedia:Template substitution. Dar-Ape 19:21, 28 November 2007 (UTC)

Template with substitution and subsequent transclusion

I am trying to build a template that includes the title of the page that is using the template. Simple enough, use:

{{FULLPAGENAME}}

However, I plan to transclude the template using page onto other pages and want a link back to the template using page automatically created. So I did the following

{{subst:FULLPAGENAME}}

But, this substituted the title of the template page and not the template using page. Not what I wanted. The solution seemed easy enough, surround the the code with includeonly tags so that the substitution occurs on the template using page rather than on the template page its self:

<includeonly>{{subst:FULLPAGENAME}}</includeonly>

The result of that, however, is to literally display "{{subst:FULLPAGENAME}}" on the template using page, not the desired result.

I've tried all sorts of other combinations, including only the "subst:", substituting the substitution, including only the substitution of the substitution, including only the included only substitution of the substitution, this thing --> {{subst:UC:{{subst:FULLPAGENAME}}}} (which wouldn't work anyways because the link back would be to a page that doesn't necessarily exist).

Advice? Suggestions? Ideas? 192.75.172.1 (talk) 19:11, 28 November 2009 (UTC)

I think I was trying for much the same effect. Try {{<includeonly>subst:</includeonly> FULLPAGENAME}} , for a working example (for now) see User:Unomi/hex. unmi 10:51, 19 August 2010 (UTC)

Clarify

Like much of help-space this is poorly written, and uses examples from Meta that don't exist here. Any wiki clarificaton would be a good thing. Rich Farmbrough, 19:49, 19 June 2010 (UTC).

utterly demotivating

I can only emphatically agree with the criticism directed at the current documentation.

I am trying to get a substitution template to evaluate prior to being substituted in, and I am not able to parse to the documentation enough to figure out how to get that done.

If someone is able to tell me how to achieve that I would be very much in their debt, in return I shall update this page :) Please see here, feel free to edit it for effect. The result of {{subst:User:Unomi/hex}} should be only the result of the evaluation, not having the logic embedded on the page, Many thanks in advance, unmi 08:47, 19 August 2010 (UTC)

It seems you found it?--Patrick (talk) 11:54, 19 August 2010 (UTC)
I managed to find a signature subst template which implements it. But it seems like something so useful that it could do with being presented here, or at least more clearly if it already is :p unmi 11:56, 19 August 2010 (UTC)
By the way, do we have any hexadecimal helpers? I see that Template:Digit uses a decimal rendition of base 16 . unmi 11:58, 19 August 2010 (UTC)
Does {{Dec2hex}} do what you want? --Redrose64 (talk) 12:35, 19 August 2010 (UTC)
Lovely! Thanks! :) unmi 12:42, 19 August 2010 (UTC)

I now see there is also {{Hexadecimal}}, when it rains it pours I guess :) unmi 12:49, 19 August 2010 (UTC)

Substituting only the template output

Is it possible to substitute only the template output, instead of all the other mess (like the switches and if-tags, etc, like in the {{Time|CET}} template)? /HeyMid (contributions) 12:14, 4 September 2010 (UTC)

See m:Help:Substitution#Multilevel substitution.--Patrick (talk) 13:17, 4 September 2010 (UTC)
I don't get it. Could you try and subst {{Time}} without all the nonsense (e.g. only the context output) here? /HeyMid (contributions) 13:52, 4 September 2010 (UTC)
Not sure what you want here. I have looked at User:Heymid/Test, and I see this:
{{[[Template:Time|Time]]}}
To create a link to a template, without transcluding it, you don't need to do this; just prefix the template name with tl|, ie {{tl|time}}, which yields {{time}}. There's a whole family of these, such as {{tlx}}. --Redrose64 (talk) 17:54, 4 September 2010 (UTC)
No. I want to transclude the template, but I don't want to include all the mess like the switches and if-tags, only the text output. /HeyMid (contributions) 18:16, 4 September 2010 (UTC)
Like here (done with {{subst:Time}}. But as you can see, it added the whole mess too. I only want the "21:32, September 4, 2010 (UTC)" part (only the outputted text) to be transcluded, not the whole mess too. Also, it seems that {{subst:Time}} does not work, returns the red error message "Invalid time". But if I do not subst it, it works fine. What is wrong with that? How can I subst a template with a {{{1}}}, {{{2}}} variable or to a named attribute?
Take my above questions one by one. /HeyMid (contributions) 21:40, 4 September 2010 (UTC)
I adapted Template:Time, Template:Time/EET offset and Template:Current daylight saving offset in Europe, the other indirectly used templates have to be adapted in a similar way.--Patrick (talk) 21:50, 4 September 2010 (UTC)
I made some more changes to Template:Time, which I forgot.--Patrick (talk) 05:57, 5 September 2010 (UTC)

Detect subst

I would like to make a template, say ABCD which has to take CURRENTDAY as a mandatory parameter. So the use of {{ABCD}} is not permitted, but users should use {{subst:ABCD}}. Now, if some user uses {{ABCD}} in an article, it should display the message Please use {{subst:ABCD}} instead of the template {{ABCD}}. How can I detect inside the template ABCD whether subst has been used or not? --Sreejith K (talk) 10:13, 18 November 2010 (UTC)

Project banners are able to do it, try sandboxing {{subst:WikiProject England}}. It's partly done with the {{substcheck}} template, also some code in {{WPBannerMeta}}. --Redrose64 (talk) 13:55, 18 November 2010 (UTC)
Splendid. I could replicate this using two templates. Great. Still, I would love to know if this can be done in a single template itself. --Sreejith K (talk) 12:29, 19 November 2010 (UTC)
I don't know if it can be done easily in one template. The discussion at Template talk:! implies that there is no existing template which would do this. --Redrose64 (talk) 13:40, 30 December 2010 (UTC)
You can use something like
{{#if:{{{{{|subst:}}}ns:0}}|transcluded|substituted}}
Patrick (talk) 16:42, 30 December 2010 (UTC)

safesubst section does not make sense

Could someone who understands safesubst: please rewrite that section of the page? It is utterly incomprehensible at the moment. It does not make it clear what safesubst: is even for, let alone how it works or how to use it. — This, that, and the other (talk) 00:55, 30 December 2010 (UTC)

I hope the section as it now stands works better than the old one.--Kotniski (talk) 11:56, 26 February 2011 (UTC)

includeonly

The page says "Use <includeonly>subst:</includeonly> in place of plain subst:. The includeonly tags break up the substitution syntax when the template is saved, but those tags will be stripped away when it is later substituted, allowing the inner substitution to take effect." I've tried this and it doesn't work. It made {{subst:PAGENAME}} appear as plain text. McLerristarr | Mclay1 09:14, 25 February 2011 (UTC)

Are you sure? I've just tried it (at User:Kotniski/Sandbox and then subst'ing at User:Kotniski/1) and it seems to work. --Kotniski (talk) 11:13, 25 February 2011 (UTC)
I tried it on User:Mclay1/Sandpit and User:Mclay1/Sandpit 2. McLerristarr | Mclay1 04:50, 26 February 2011 (UTC)
So it should work, as long as you do the "subst:" in Sandpit 2. (It won't work on transclusion, as explained elsewhere on the page, although you could use "safesubst:" in place of "subst:" in Sandpit to give the same result at Sandpit 2 even on transclusion.)--Kotniski (talk) 11:59, 26 February 2011 (UTC)
Thank you McLerristarr | Mclay1 14:49, 28 February 2011 (UTC)

Safesubst: is jargon loaded

To me the explanation of safesubst:, while it may be right, it isn't very helpful. It uses jargon and packs it in so tight that I cannot work out what it is saying or meaning. That being the case if there is no other means to explain it, then we should look to examples. If we could look to clearly state when it should be used, and what makes it "safe" that would be great. 112.213.156.24 (talk) 12:44, 12 April 2011 (UTC)

subst:PAGENAME versus subst::PAGENAME

I was never able to get subst:PAGENAME to work. Then I found this:

http://www.mediawiki.org/wiki/Help:Templates#Usage

Which mentions using subst::PAGENAME with two colons instead of one. That worked for me, and is apparently undocumented on any page (wikipedia, mediawiki, wikimedia, or metawiki) that is dedicated to documenting substitution. Is it just me, or is having documentation spread out across 4 different sites a contributing factor for poor documentation in general, and of substitution in particular?

Badon (talk) 19:08, 12 September 2011 (UTC)

It's an old question but for interested readers, {{subst:PAGENAME}} works on "Template:PAGENAME" while {{subst::PAGENAME}} works on the mainspace page "PAGENAME". It's like normal transclusion where {{:PAGENAME}} transcludes a mainspace page instead of a template. It's mentioned in Help:Substitution#Syntax and was also there in 2011. PrimeHunter (talk) 15:34, 28 September 2022 (UTC)

Clarify Help:Substitution#Limitation

Much of this is unclear and needs to be reworked by a technical writer

#tag:ref not supporting ref names?

Why is Subst leaving conditional cruft after transclusion

TLDR version for dummies?

Substituting templates after they already have been transcluded

Cleanup

<nosubst>

A complex safesubst'ing job

O Brother ... Granted, subst doc/help pages are not as bad as SMW doc pages. But really useful ... not if you ask me.

Related Articles

Wikiwand AI