Jump to content
Toggle menu
  • 8 articles
  • 75 files
  • 7 users
  • 37.8K edits
Neodyland Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:Iffile: Difference between revisions

Template page
m Image -> File fix
No edit summary
Tags: Manual revert 2017 source edit
 
(9 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{#ifeq:{{NAMESPACE}}|File|{{{1|}}}}}<noinclude>
{{#ifexpr:{{NAMESPACENUMBER}}=6|{{{1|}}}|{{{2|}}}}}<noinclude>


 
{{heavily used template}}
----
{{Documentation}}
For use in templates that add images to categories (while having no effect in all other namespaces). Short for <code><nowiki>{{#ifeq:{{NAMESPACE}}|File|</nowiki></code>...<code>}}</code>.
 
For example, something like <nowiki>{{ifimage|[[Category:Some media only category]]}}</nowiki> might go in a template that's only supposed to categorize images. Of course, <nowiki><includeonly></nowiki> tags aren't needed since it won't affect templates. No type of category suppression (e.g. <code>category=</code> or <code>|nocat</code>) is needed on demo/example pages either.
 
[[Category:Function templates|{{PAGENAME}}]]
</noinclude>
</noinclude>

Latest revision as of 17:23, 12 August 2026


Template documentation[ view · edit · history · purge ]
This documentation is transcluded from Template:Iffile/doc.

Shorthand to display something only in the File namespace

Usage

{{Iffile |1= |2= }}

Short for {{#ifeq:{{NAMESPACE}}|File|...}},
Shortf or {{#ifeq:{{NAMESPACENUMBER}}|6|...}}.

Intended usage is for templates that should categorise only when used in File namespace.

Template parameters

<templatedata>JSON</templatedata> ./. {{TemplateBox}}
TemplateData

TemplateData is a way to store information about template parameters (the description of those and of the whole template) for both humans and machines. It is used by VisualEditor and possibly other tools like Upload Wizard.


Existing template documentation
At Wikimedia Commons, it is recommended to use {{TemplateBox}} with either ‎useTemplateData=1 or ‎useTemplateData=only on the ‎/doc subpage and transcluding it with {{Documentation}} into the template. ‎<nowiki>-tags can be wrapped around the arguments, if required, to avoid templates being expanded.

Newly created template documentation and imports
Another option, especially for imported templates, or for users with JSON experience, is placing raw ‎<templatedata>-tags into the Wikitext of the template, as described in various Wikipediae.


Wikipedia's help about TemplateDataCommons-specific information

Shorthand to display something only in the File namespace

Template parameters[Edit template data]

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
file namespace1

The wikitext to display if the test is conclusive

Contentrequired
non-file namespace2

The wikitext to display if the test isn’t conclusive

Contentoptional

Additional information

The template is intended to be used in the following namespaces: all namespaces

The template is intended to be used by the following user groups: all users

See also

Localization

This template is not intended to be localized.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.