Difference between revisions of "Template:IMDb title/testcases"

From blackwiki
Jump to navigation Jump to search
imported>Zyxw
(update testcases for current version of template)
imported>Zyxw
(use {{Test case}} to highlight any differences between main template and sandbox, add tests for empty id/title parameters, add brief descriptions of expected output)
Line 3: Line 3:
 
== No parameters ==
 
== No parameters ==
  
Usage: <code>{{((}} {{BASEPAGENAME}} {{))}}</code>
+
If no ID is provided, the template uses [[Wikidata]] property {{wpl|P345}}:
* Output: {{ {{BASEPAGENAME}} }}
+
: <kbd><nowiki>https://www.imdb.com/title/{{#property:P345}}/</nowiki></kbd>
* Sandbox: {{ {{BASEPAGENAME}}/sandbox }}
+
If the page does not have a Wikidata item containing that property, the template uses the page name:
 +
: <kbd><nowiki>https://www.imdb.com/Title?{{urlencode:{{PAGENAME}}}}/</nowiki></kbd>
 +
: The template also adds [[:Category:IMDb template with no id set]] if the page is located in the [[WP:NS0|main or article namespace]].
 +
The [[link text]] should be the Wikipedia page name, without disambiguation (via {{tlg|kbd=yes|PAGENAMEBASE}}).
 +
 
 +
{{Test case nowiki|format=inline|collapsible=yes|title=No parameters
 +
|code=<nowiki>{{__TEMPLATENAME__}}</nowiki>
 +
}}
 +
 
 +
{{Test case nowiki|format=inline|collapsible=yes|title=empty ID (unnamed parameter)
 +
|code=<nowiki>{{__TEMPLATENAME__ | }}</nowiki>
 +
}}
 +
{{Test case nowiki|format=inline|collapsible=yes|title=empty ID (named parameter)
 +
|code=<nowiki>{{__TEMPLATENAME__ | id= }}</nowiki>
 +
}}
 +
 
 +
{{Test case nowiki|format=inline|collapsible=yes|title=empty ID and Title (unnamed parameters)
 +
|code=<nowiki>{{__TEMPLATENAME__ | | }}</nowiki>
 +
}}
 +
{{Test case nowiki|format=inline|collapsible=yes|title=empty ID and Title (named parameters)
 +
|code=<nowiki>{{__TEMPLATENAME__ | id= | title= }}</nowiki>
 +
}}
  
 
== Parameter: id (1) ==
 
== Parameter: id (1) ==
  
Usage: <code>{{((}} {{BASEPAGENAME}} {{!}} id= 0111282 {{))}}</code>
+
If the ID does not start with "tt", the template adds "tt" (and leading zeros, if needed):
* Output: {{ {{BASEPAGENAME}} | id= 0111282 }}
+
: <kbd>0111282 — https://<nowiki/>www.imdb.com/title/{{Hilite|tt|lightgreen}}{{Hilite|0111282}}/</kbd>
* Sandbox: {{ {{BASEPAGENAME}}/sandbox | id= 0111282 }}  
+
: <kbd>111282 — https://<nowiki/>www.imdb.com/title/{{Hilite|tt0|lightgreen}}{{Hilite|111282}}/</kbd>
 +
If the ID starts with "tt", the template does not make any changes:
 +
: <kbd>tt0111282 — https://<nowiki/>www.imdb.com/title/{{Hilite|tt0111282}}/</kbd> (valid ID)
 +
: <kbd>tt111282 — https://<nowiki/>www.imdb.com/title/{{Hilite|tt111282}}/</kbd> (invalid ID)
 +
: An article using {{tlc|{{BASEPAGENAME}}|tt111282}} would be added to [[:Category:IMDb template with invalid id set]]
 +
The [[link text]] should be the Wikipedia page name, without disambiguation (via {{tlg|kbd=yes|PAGENAMEBASE}}).
 +
 
 +
{{Test case nowiki|format=inline|collapsible=yes|title=ID number with leading zeros (unnamed parameter)
 +
|code=<nowiki>{{__TEMPLATENAME__ | 0111282 }}</nowiki>
 +
}}
 +
{{Test case nowiki|format=inline|collapsible=yes|title=ID number with leading zeros (named parameter)
 +
|code=<nowiki>{{__TEMPLATENAME__ | id= 0111282 }}</nowiki>
 +
}}
  
Usage: <code>{{((}} {{BASEPAGENAME}} {{!}} id= tt0111282 {{))}}</code>
+
{{Test case nowiki|format=inline|collapsible=yes|title=ID number without leading zeros (unnamed parameter)
* Output: {{ {{BASEPAGENAME}} | id= tt0111282 }}
+
|code=<nowiki>{{__TEMPLATENAME__ | 111282 }}</nowiki>
* Sandbox: {{ {{BASEPAGENAME}}/sandbox | id= tt0111282 }}  
+
}}
 +
{{Test case nowiki|format=inline|collapsible=yes|title=ID number without leading zeros (named parameter)
 +
|code=<nowiki>{{__TEMPLATENAME__ | id= 111282 }}</nowiki>
 +
}}
  
Usage: <code>{{((}} {{BASEPAGENAME}} {{!}} 0001109 {{))}}</code>
+
{{Test case nowiki|format=inline|collapsible=yes|title=ID with "tt" and leading zeros (unnamed parameter)
* Output: {{ {{BASEPAGENAME}} | 0001109 }}
+
|code=<nowiki>{{__TEMPLATENAME__ | tt0111282 }}</nowiki>
* Sandbox: {{ {{BASEPAGENAME}}/sandbox | 0001109 }}  
+
}}
 +
{{Test case nowiki|format=inline|collapsible=yes|title=ID with "tt" and leading zeros (named parameter)
 +
|code=<nowiki>{{__TEMPLATENAME__ | id= tt0111282 }}</nowiki>
 +
}}
  
Usage: <code>{{((}} {{BASEPAGENAME}} {{!}} tt0111282 {{))}}</code>
+
{{Test case nowiki|format=inline|collapsible=yes|title=ID with "tt" without leading zeros (unnamed parameter)
* Output: {{ {{BASEPAGENAME}} | tt0111282 }}
+
|code=<nowiki>{{__TEMPLATENAME__ | tt111282 }}</nowiki>
* Sandbox: {{ {{BASEPAGENAME}}/sandbox | tt0111282 }}  
+
}}
 +
{{Test case nowiki|format=inline|collapsible=yes|title=ID with "tt" without leading zeros (named parameter)
 +
|code=<nowiki>{{__TEMPLATENAME__ | id= tt111282 }}</nowiki>
 +
}}
 +
 
 +
{{Test case nowiki|format=inline|collapsible=yes|title=ID and empty Title (unnamed parameters)
 +
|code=<nowiki>{{__TEMPLATENAME__ | 0111282 | }}</nowiki>
 +
}}
 +
{{Test case nowiki|format=inline|collapsible=yes|title=ID and empty Title (named parameters)
 +
|code=<nowiki>{{__TEMPLATENAME__ | id= 0111282 | title= }}</nowiki>
 +
}}
  
 
== Parameter: title (2) ==
 
== Parameter: title (2) ==
  
Usage: <code>{{((}} {{BASEPAGENAME}} {{!}} id= 0111282 {{!}} title= Stargate {{))}}</code>
+
{{Test case nowiki|format=inline|collapsible=yes|title=ID and Title (unnamed parameters)
* Output: {{ {{BASEPAGENAME}} | id= 0111282 | title= Stargate }}
+
|code=<nowiki>{{__TEMPLATENAME__ | 0111282 | Stargate }}</nowiki>
* Sandbox: {{ {{BASEPAGENAME}}/sandbox | id= 0111282 | title= Stargate }}
+
}}
 
+
{{Test case nowiki|format=inline|collapsible=yes|title=ID and Title (named parameters)
Usage: <code>{{((}} {{BASEPAGENAME}} {{!}} 0111282 {{!}} Stargate {{))}}</code>
+
|code=<nowiki>{{__TEMPLATENAME__ | id= 0111282 | title= Stargate }}</nowiki>
* Output: {{ {{BASEPAGENAME}} | 0111282 | Stargate }}
+
}}
* Sandbox: {{ {{BASEPAGENAME}}/sandbox | 0111282 | Stargate }}  
 
  
 
== Parameter: description (3) ==
 
== Parameter: description (3) ==
  
Usage: <code>{{((}} {{BASEPAGENAME}} {{!}} id= 0111282 {{!}} title= Stargate {{!}} description= (1994 film) {{))}}</code>
+
Any text in {{para|description}} is added after the title, inside the [[link text]].
* Output: {{ {{BASEPAGENAME}} | id= 0111282 | title= Stargate | description= (1994 film) }}
 
* Sandbox: {{ {{BASEPAGENAME}}/sandbox | id= 0111282 | title= Stargate | description= (1994 film) }}
 
  
Usage: <code>{{((}} {{BASEPAGENAME}} {{!}} 0111282 {{!}} Stargate {{!}} (1994 film) {{))}}</code>
+
{{Test case nowiki|format=inline|collapsible=yes|title=description (unnamed parameters for ID and Title)
* Output: {{ {{BASEPAGENAME}} | 0111282 | Stargate | (1994 film) }}
+
|code=<nowiki>{{__TEMPLATENAME__ | 0111282 | Stargate | description= (1994 film) }}</nowiki>
* Sandbox: {{ {{BASEPAGENAME}}/sandbox | 0111282 | Stargate | (1994 film) }}  
+
}}
 +
{{Test case nowiki|format=inline|collapsible=yes|title=description (named parameters for ID and Title)
 +
|code=<nowiki>{{__TEMPLATENAME__ | id= 0111282 | title= Stargate | description= (1994 film) }}</nowiki>
 +
}}
  
 
== Parameter: section ==
 
== Parameter: section ==
  
=== award ===
+
If {{para|section|awards}} or {{para|section|award}}:
 +
: "Awards for " is added before the title, inside the [[link text]]
 +
: <kbd>awards</kbd> is added to the end of the URL: <kbd>https://<nowiki/>www.imdb.com/title/tt#######/{{Hilite|awards}}</kbd>
 +
Any other values in {{para|section}} are ignored.
  
Usage: <code>{{((}} {{BASEPAGENAME}} {{!}} id= 0111282 {{!}} title= Stargate {{!}} section= award {{))}}</code>
+
{{Test case nowiki|format=inline|collapsible=yes|title=awards (unnamed parameters for ID and Title)
* Output: {{ {{BASEPAGENAME}} | id= 0111282 | title= Stargate | section= award }}
+
|code=<nowiki>{{__TEMPLATENAME__ | 0111282 | Stargate | section= awards }}</nowiki>
* Sandbox: {{ {{BASEPAGENAME}}/sandbox | id= 0111282 | title= Stargate | section= award }}  
+
}}
 +
{{Test case nowiki|format=inline|collapsible=yes|title=awards (named parameters for ID and Title)
 +
|code=<nowiki>{{__TEMPLATENAME__ | id= 0111282 | title= Stargate | section= awards }}</nowiki>
 +
}}
  
Usage: <code>{{((}} {{BASEPAGENAME}} {{!}} 0111282 {{!}} Stargate {{!}} section= award {{))}}</code>
+
{{Test case nowiki|format=inline|collapsible=yes|title=award (unnamed parameters for ID and Title)
* Output: {{ {{BASEPAGENAME}} | 0111282 | Stargate | section= award }}
+
|code=<nowiki>{{__TEMPLATENAME__ | 0111282 | Stargate | section= award }}</nowiki>
* Sandbox: {{ {{BASEPAGENAME}}/sandbox | 0111282 | Stargate | section= award }}
+
}}
 +
{{Test case nowiki|format=inline|collapsible=yes|title=award (named parameters for ID and Title)
 +
|code=<nowiki>{{__TEMPLATENAME__ | id= 0111282 | title= Stargate | section= award }}</nowiki>
 +
}}
  
=== awards ===
+
{{Test case nowiki|format=inline|collapsible=yes|title=other (unnamed parameters for ID and Title)
 +
|code=<nowiki>{{__TEMPLATENAME__ | 0111282 | Stargate | section= other }}</nowiki>
 +
}}
 +
{{Test case nowiki|format=inline|collapsible=yes|title=other (named parameters for ID and Title)
 +
|code=<nowiki>{{__TEMPLATENAME__ | id= 0111282 | title= Stargate | section= other }}</nowiki>
 +
}}
  
Usage: <code>{{((}} {{BASEPAGENAME}} {{!}} id= 0111282 {{!}} title= Stargate {{!}} description= (1994 film)  {{!}} section= awards {{))}}</code>
+
== All parameters ==
* Output: {{ {{BASEPAGENAME}} | id= 0111282 | title= Stargate | description= (1994 film) | section= awards }}
 
* Sandbox: {{ {{BASEPAGENAME}}/sandbox | id= 0111282 | title= Stargate | description= (1994 film) | section= awards }}
 
  
Usage: <code>{{((}} {{BASEPAGENAME}} {{!}} 0111282 {{!}} Stargate {{!}} (1994 film) {{!}} section= awards {{))}}</code>
+
{{Test case nowiki|format=inline|collapsible=yes|title=description and awards (unnamed parameters for ID and Title)
* Output: {{ {{BASEPAGENAME}} | 0111282 | Stargate | (1994 film) | section= awards }}
+
|code=<nowiki>{{__TEMPLATENAME__ | 0111282 | Stargate | description= (1994 film) | section= awards }}</nowiki>
* Sandbox: {{ {{BASEPAGENAME}}/sandbox | 0111282 | Stargate | (1994 film) | section= awards }}
+
}}
 +
{{Test case nowiki|format=inline|collapsible=yes|title=description and awards (named parameters for ID and Title)
 +
|code=<nowiki>{{__TEMPLATENAME__ | id= 0111282 | title= Stargate | description= (1994 film) | section= awards }}</nowiki>
 +
}}

Revision as of 19:24, 28 July 2018

  1. REDIRECT Template:Testcases notice
  • From a page move: This is a redirect from a page that has been moved (renamed). This page was kept as a redirect to avoid breaking links, both internal and external, that may have been made to the old page name.

No parameters

If no ID is provided, the template uses Wikidata property Template:Wpl:

https://www.imdb.com/title/{{#property:P345}}/

If the page does not have a Wikidata item containing that property, the template uses the page name:

https://www.imdb.com/Title?{{urlencode:{{PAGENAME}}}}/
The template also adds Category:IMDb template with no id set if the page is located in the main or article namespace.

The link text should be the Wikipedia page name, without disambiguation (via {{PAGENAMEBASE}}).

No parameters
  • {{IMDb title}}Template:PAGENAMEBASE at IMDbScript error: No such module "EditAtWikidata".Expression error: Unrecognized punctuation character "[".
  • {{IMDb title/sandbox}}Template:PAGENAMEBASE at IMDbScript error: No such module "EditAtWikidata".Expression error: Unrecognized punctuation character "[".
empty ID (unnamed parameter)
  • {{IMDb title | }}Template:PAGENAMEBASE at IMDbScript error: No such module "EditAtWikidata".Expression error: Unrecognized punctuation character "[".
  • {{IMDb title/sandbox | }}Template:PAGENAMEBASE at IMDbScript error: No such module "EditAtWikidata".Expression error: Unrecognized punctuation character "[".
empty ID (named parameter)
  • {{IMDb title | id= }}Template:PAGENAMEBASE at IMDbScript error: No such module "EditAtWikidata".Expression error: Unrecognized punctuation character "[".
  • {{IMDb title/sandbox | id= }}Template:PAGENAMEBASE at IMDbScript error: No such module "EditAtWikidata".Expression error: Unrecognized punctuation character "[".
empty ID and Title (unnamed parameters)
  • {{IMDb title | | }}Template:PAGENAMEBASE at IMDbScript error: No such module "EditAtWikidata".Expression error: Unrecognized punctuation character "[".
  • {{IMDb title/sandbox | | }}Template:PAGENAMEBASE at IMDbScript error: No such module "EditAtWikidata".Expression error: Unrecognized punctuation character "[".
empty ID and Title (named parameters)
  • {{IMDb title | id= | title= }}Template:PAGENAMEBASE at IMDbScript error: No such module "EditAtWikidata".Expression error: Unrecognized punctuation character "[".
  • {{IMDb title/sandbox | id= | title= }}Template:PAGENAMEBASE at IMDbScript error: No such module "EditAtWikidata".Expression error: Unrecognized punctuation character "[".

Parameter: id (1)

If the ID does not start with "tt", the template adds "tt" (and leading zeros, if needed):

0111282 — https://www.imdb.com/title/tt0111282/
111282 — https://www.imdb.com/title/tt0111282/

If the ID starts with "tt", the template does not make any changes:

tt0111282 — https://www.imdb.com/title/tt0111282/ (valid ID)
tt111282 — https://www.imdb.com/title/tt111282/ (invalid ID)
An article using {{IMDb title|tt111282}} would be added to Category:IMDb template with invalid id set

The link text should be the Wikipedia page name, without disambiguation (via {{PAGENAMEBASE}}).

ID number with leading zeros (unnamed parameter)
ID number with leading zeros (named parameter)
ID number without leading zeros (unnamed parameter)
ID number without leading zeros (named parameter)
ID with "tt" and leading zeros (unnamed parameter)
  • {{IMDb title | tt0111282 }}Template:PAGENAMEBASE at IMDbScript error: No such module "EditAtWikidata".Expression error: Unrecognized punctuation character "[".
  • {{IMDb title/sandbox | tt0111282 }}Template:PAGENAMEBASE at IMDbScript error: No such module "EditAtWikidata".Expression error: Unrecognized punctuation character "[".
ID with "tt" and leading zeros (named parameter)
  • {{IMDb title | id= tt0111282 }}Template:PAGENAMEBASE at IMDbScript error: No such module "EditAtWikidata".Expression error: Unrecognized punctuation character "[".
  • {{IMDb title/sandbox | id= tt0111282 }}Template:PAGENAMEBASE at IMDbScript error: No such module "EditAtWikidata".Expression error: Unrecognized punctuation character "[".
ID with "tt" without leading zeros (unnamed parameter)
  • {{IMDb title | tt111282 }}Template:PAGENAMEBASE at IMDbScript error: No such module "EditAtWikidata".Expression error: Unrecognized punctuation character "[".
  • {{IMDb title/sandbox | tt111282 }}Template:PAGENAMEBASE at IMDbScript error: No such module "EditAtWikidata".Expression error: Unrecognized punctuation character "[".
ID with "tt" without leading zeros (named parameter)
  • {{IMDb title | id= tt111282 }}Template:PAGENAMEBASE at IMDbScript error: No such module "EditAtWikidata".Expression error: Unrecognized punctuation character "[".
  • {{IMDb title/sandbox | id= tt111282 }}Template:PAGENAMEBASE at IMDbScript error: No such module "EditAtWikidata".Expression error: Unrecognized punctuation character "[".
ID and empty Title (unnamed parameters)
ID and empty Title (named parameters)

Parameter: title (2)

ID and Title (unnamed parameters)
ID and Title (named parameters)

Parameter: description (3)

Any text in |description= is added after the title, inside the link text.

description (unnamed parameters for ID and Title)
description (named parameters for ID and Title)

Parameter: section

If |section=awards or |section=award:

"Awards for " is added before the title, inside the link text
awards is added to the end of the URL: https://www.imdb.com/title/tt#######/awards

Any other values in |section= are ignored.

awards (unnamed parameters for ID and Title)
awards (named parameters for ID and Title)
award (unnamed parameters for ID and Title)
award (named parameters for ID and Title)
other (unnamed parameters for ID and Title)
other (named parameters for ID and Title)

All parameters

description and awards (unnamed parameters for ID and Title)
description and awards (named parameters for ID and Title)