VOOZH about

URL: https://minecraft.wiki/w/Template:Ifcategory

⇱ Template:Ifcategory – Minecraft Wiki


Template:Ifcategory

From Minecraft Wiki
Jump to navigation Jump to search
Documentation[view] [edit] [history] [purge]
This template uses Module:Ifcategory, a script written in Lua.

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.

Usage

{{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.

Template data

Template parameters[Edit template data]

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Category1

Category the page should be in

Example
Blocks
Stringrequired
Yes2

If the page is in the category, contents of this parameter is used as output.

Stringrequired
No3

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.

Stringoptional
Pagepage

Which page to check category for

Default
The current page
Page nameoptional
No if page is nonexistentnoIfNonexistent

Instead of throwing an error, output the no text if the page to check for does not exist.

Default
false
Example
1
Booleanoptional
[view] [edit] [history] [purge]The above documentation is transcluded from Template:Ifcategory/doc.
Retrieved from "https://minecraft.wiki/w/Template:Ifcategory?oldid=3529851"

Navigation menu