Anonymous
Not logged in
Talk
Contributions
Create account
Log in
Guild of Archivists
Search
Editing
Template:When pagename is/doc
From Guild of Archivists
Namespaces
Template
Discussion
More
More
Page actions
Read
Edit
History
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Documentation subpage}} <!--Categories where indicated at the bottom of this page, please; interwikis at Wikidata (see [[Wikipedia:Wikidata]])--> This is the {{tl|When pagename is}} meta-template. It helps other templates detect what page they are on, using pattern matching on the pagename. == Usage == This template takes one or more parameters. Most of the parameters don't have fixed names, instead they are part of the pattern matching. Like this: <pre> {{When pagename is | /doc = Doc page text | other = Other pages text }} </pre> If the template is on "Template:Example/doc" the code above will return this: : {{When pagename is | /doc = Doc page text | other = Other pages text | page = Template:Example/doc }} If the template is on any ''other'' page than a /doc page it will return this: : {{When pagename is | /doc = Doc page text | other = Other pages text | page = Template:Example }} Here is a description of the full pattern matching: <pre> {{When pagename is <!-- Match on full pagename --> | User:Example/test = Text for "User:Example/test". | User:Example = Text for "User:Example". | User talk:Example = Text for "User talk:Example". <!-- Match on full basepage name, when on a basepage or its subpages --> | User:Example/+ = Matches "User:Example" and "User:Example/test". <!-- Match on pagename, when on a basepage --> | Example = Matches "User:Example", "User talk:Example", "Template:Example" and so on, but not "User:Example/something". <!-- Match on full basepage name, when on a subpage --> | User:Example/* = Matches "User:Example/something", but not "User:Example". | User talk:Example/* = Matches "User talk:Example/something". <!-- Match on basepage name, when on a subpage --> | Example/* = Matches "User:Example/something" and "User talk:Example/something". <!-- Match on subpage name --> | /something = Any pagename that ends in "/something". | /doc = Any pagename that ends in "/doc". <!-- Match on partial subpage name (case-insensitive) --> | /some* = Any subpage name beginning with "/some" or "/Some". | /arch* = Matches "User talk:Example/Archive 1". <!-- Defaults --> | basepage = Text for any basepage. | subpage = Text for any subpage. | other = Text for any page. }} </pre> The matching goes from top to bottom, and returns the first parameter that matches. "''Top to bottom''" means the order shown above, not the order you happen to feed the parameters. There's no limit to the number of parameters that you can use, other than what the servers and MediaWiki system can handle. Most of the matching is case-sensitive. For instance "<code>/test</code>" matches "User:Example/test" but not "User:Example/Test". Matching on partial subpage names such as "<code>/some*</code>" has some limitations, see [[#Partial subpage names|its own section]] below. If an empty (but defined) parameter matches, the matching stops and the template returns an empty string. That's on purpose and can be used like this: <pre> {{When pagename is | /doc = | /sandbox = Sandbox text | other = Other pages text }} </pre> The code above will render nothing when on a /doc page. But when on a /sandbox page it will return this: : {{When pagename is | /doc = | /sandbox = Sandbox text | other = Other pages text | page = Template:Example/sandbox }} And when on any other page it will return this: : {{When pagename is | /doc = | /sandbox = Sandbox text | other = Other pages text | page = Template:Example }} == Partial subpage names == This template can also match on partial subpage names. Like this: <pre> {{When pagename is | /archiv* = Archive page text | other = Other pages text }} </pre> If on "User:Example/Archive 1" the code above will return this: : {{When pagename is | /archiv* = Archive page text | other = Other pages text | page = User:Example/Archive 1 }} The parameter name "<code>/some*</code>" must be lower case. But it matches subpage names in both upper and lower case such as "User:Example/SomeThing" and "User:Example/something". The partial matching only supports matching on 4, 6 and 8 characters. Thus using "<code>/some*</code>", "<code>/someth*</code>" and "<code>/somethin*</code>" works, but using "<code>/som*</code>" or "<code>/somet*</code>" doesn't work. Longer patterns match first, thus if both "<code>/somethin*</code>" and "<code>/some*</code>" are defined, and the current page is "User:Example/Something", then the data from "<code>/somethin*</code>" will be used. == "page" parameter == For testing and demonstration purposes this template can take a parameter named '''page'''. Like this: <pre> {{When pagename is | /test = Test pages text | other = Other pages text | page = Template:Example/test }} </pre> No matter on what kind of page the code above is used it will return this: : {{When pagename is | /test = Test pages text | other = Other pages text | page = Template:Example/test }} The '''page''' parameter makes this template behave exactly as if on that page. The pagename doesn't have to be an existing page. If the '''page''' parameter is empty or undefined, the name of the current page determines the result. You can make it so your template also understands the '''page''' parameter. That means you can demonstrate the different appearances of your template in the documentation for your template. Then do like this: <pre> {{When pagename is | /test = Test pages text | other = Other pages text | page = {{{page|}}} }} </pre> == Namespace matching == This template doesn't have namespace matching. == Technical details == This template detects subpages even when used in namespaces that don't have the MediaWiki subpage feature enabled. Thus this template works the same in all namespaces. <includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | | <!--Categories below this line, please; interwikis at Wikidata--> [[Category:If-then-else templates]] [[Category:Namespace manipulation templates]] }}</includeonly>
Summary:
Please note that all contributions to Guild of Archivists may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
GoArch:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Documentation subpage
(
edit
)
Template:Mbox
(
edit
)
Template:Tl
(
edit
)
Template:When pagename is
(
edit
)
Module:Arguments
(
edit
)
Module:Message box
(
edit
)
Module:Message box/configuration
(
edit
)
Module:No globals
(
edit
)
Module:Yesno
(
edit
)
Navigation
Navigation
Main Page
Random page
Categories
All pages
Recent changes
Resources
Dictionaries
Reference material
Utilities
Community
Forums
Jalak Game Directory
Projects
Apocrypha
Unexplored Branches
All projects
Contribute
Stubs
Wanted
Cleanup
Dead ends
Image requested
Help
Help
Guide
Policies
Wiki tools
Wiki tools
Special pages
Page values
Page tools
Page tools
User page tools
More
What links here
Related changes
Page information
Page logs