![]() |
VOOZH | about |
Similar to the {{#if:}}} parser function, this template checks if a page is in a category (first unnamed param), and outputs either the second or third unnamed parameter.
{{ifcategory|Lua-based templates|this template uses lua|this template does not use lua}}
gives this template uses lua since this page is in Category:Lua-based templates.
{{ifcategory|page=Stone|Blocks|stone is a block|stone is not a block}}
gives stone is a block since Stone is in Category:Blocks.
{{ifcategory|page=Nonexistent|noIfNonexistent=1|Blocks|this would have thrown an error|but it doesn't since <code>noIfNonexistent</code> is set}}
gives
but it doesn't since noIfNonexistent is set. This will suppress the error and output the third unnamed parameter.
| Parameter | Description | Type | Status | |
|---|---|---|---|---|
| Category | 1 | Category the page should be in
| String | required |
| Yes | 2 | If the page is in the category, contents of this parameter is used as output. | String | required |
| No | 3 | If the page is NOT in the category, contents of this parameter is used as output. If this is parameter is not present, nothing is output. | String | optional |
| Page | page | Which page to check category for
| Page name | optional |
| No if page is nonexistent | noIfNonexistent | Instead of throwing an error, output the no text if the page to check for does not exist.
| Boolean | optional |