Predloga:Osnovnastran podstran
Predloga se uporablja na številnih straneh. Z urejanjem te predloge lahko zelo obremenite strežnike, zato pred uvedbo vse spremembe, ki jih želite uvesti, preizkusite na njenih podstraneh (/peskovnik oziroma /testniprimeri) ali na svojih lastnih podstraneh. Preizkusite jih lahko tudi v posebnem peskovniku za predloge. Preizkušene spremembe se lahko v predlogo dodajo z enim samim urejanjem. Preden predlogo spremenite, se o spremembah rajši pogovorite na njeni pogovorni strani. |
To je meta-predloga {{osnovnastran podstran}}.
Ta predloga pomaga drugim predlogam detektirati, če se nahajajo na osnovni strani (basepage), podstrani (subpage) ali podpodstrani.
Uporaba
[uredi kodo]This template takes one or more parameters, like this:
{{osnovnastran podstran | Basepage text | Subpage text }}
If the template is on the page "Uporabnik:Primer", it will return this:
- Basepage text
If the template is on "Uporabnik:Primer/test" or "Uporabnik:Primer/test/test" or any page lower than that, it will return this:
- Subpage text
This template can also detect "subsubpages", like this:
{{osnovnastran podstran | Basepage text | Subpage text | Subsubpage text }}
If the template is on "Uporabnik:Primer/test/test" or any page lower than that, it will return this:
- Subsubpage text
By using an empty parameter you can make it so the template doesn't render anything for some specific page type. Like this:
{{osnovnastran podstran | Basepage text | Subpage text | }}
The code above will render nothing when on "User:Example/test/test" or lower, but will return this when on "User:Example/test":
- Subpage text
The "page" parameter
[uredi kodo]For testing and demonstration purposes this template can take a parameter named page. Like this:
{{osnovnastran podstran | Basepage text | Subpage text | page = Uporabnik:Primer/test }}
No matter on what kind of page the code above is used it will return this:
- Subpage text
The page parameter makes this template behave exactly as if on that page. Thus, if a subsubpagename like "User:Example/test/test" is fed, then it returns the subsubpage text if there is one, otherwise it returns the subpage text.
The pagename doesn't have to be an existing page.
If the 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:
{{osnovnastran podstran | Basepage text | Subpage text | page = {{{page|}}} }}
Technical details
[uredi kodo]Templates have a problem to handle parameter data that contains equal signs "=
". But that is easily solved by using numbered parameters. Like this:
{{osnovnastran podstran | 1 = Basepage text | 2 = Subpage text | 3 = Subsubpage text | page = {{{page|}}} }}
This template detects subpages even when used in namespaces that doesn't have the MediaWiki subpage feature enabled. Thus this template works the same in all namespaces.
See also
[uredi kodo]Pagename-handling and detection templates:
- {{basepage subpage}} – For detecting if on a basepage, subpage or subsubpage.
- {{pgn}} – Can take apart and put together pagenames in several ways.
- {{if pagename}} – For pattern matching on the pagename.
- {{if pagename multi}} – For pattern matching on the pagename, has input reuse.
- {{IP-user other}} – For detecting IP-user pages.
- {{IP-talk}} - Return: 1) IP user talk page 2) registered user talk page 3) not user talk page.
Easy to use namespace-detection templates:
- {{main other}} – For article templates.
- {{talk other}} – For talk page templates.
- {{user other}} – For user page templates.
- {{wikipedia other}} – For detecting "Wikipedia:" pages.
- {{file other}} – For file (image) templates.
- {{template other}} – For detecting template pages.
- {{help other}} – For help page templates.
- {{category other}} – For category templates.
- {{portal other}} – For portal templates.
- {{book other}} – For detecting book pages.
More complex namespace-detection templates:
- {{namespace detect}} – The very versatile one.
- {{namespace detect showall}} – The extremely versatile one, has input reuse.
- {{talkspace detect}} - For detecting talk pages on various namespaces.
Technical stuff:
- mw:Help:Magic words – About
{{NAMESPACE}}
etc. - mw:Help:Extension:ParserFunctions – About
{{#ifeq:|||}}
etc.