Actions

Template

Difference between revisions of "CatInclude"

From Joomla! Documentation

m (now include it)
m (spelling)
 
Line 1: Line 1:
 
{{#switch: {{NAMESPACE}}
 
{{#switch: {{NAMESPACE}}
|Template=<!-- no categorization -->
+
|Template=<!-- no categorisation -->
|JDOC=<!-- no categorization -->
+
|JDOC=<!-- no categorisation -->
 
|Category=<!-- no categorisation -->
 
|Category=<!-- no categorisation -->
 
|#default={{#arraydefine:cats|{{{1|}}}}} {{#arrayprint:cats||@@@@|[[Category:@@@@|{{PAGENAME}}]]}}{{#arrayreset:cats}}
 
|#default={{#arraydefine:cats|{{{1|}}}}} {{#arrayprint:cats||@@@@|[[Category:@@@@|{{PAGENAME}}]]}}{{#arrayreset:cats}}
Line 8: Line 8:
 
{{#switch: {{NAMESPACE}}
 
{{#switch: {{NAMESPACE}}
 
|Template=<!-- no categorisation -->
 
|Template=<!-- no categorisation -->
|JDOC=<!-- no categorizsation -->
+
|JDOC=<!-- no categorisation -->
 
|Category=<!-- no categorisation -->
 
|Category=<!-- no categorisation -->
 
|#default={{#arraydefine:cats|{{{1|}}}}} {{#arrayprint:cats||@@@@|[[Category:@@@@|{{PAGENAME}}]]}}{{#arrayreset:cats}}
 
|#default={{#arraydefine:cats|{{{1|}}}}} {{#arrayprint:cats||@@@@|[[Category:@@@@|{{PAGENAME}}]]}}{{#arrayreset:cats}}

Latest revision as of 10:13, 15 January 2014

The {{CatInclude}} template makes category inclusion in other templates easier. It eliminates the need for complicated #switches and #ifeq of NAMESPACE to allow category inclusion in templates without including those categories in certain NAMESPACES such as, the Template and JDOC NAMESPACES. The code being used is shown below.

{{#switch: {{NAMESPACE}}
|Template=<!-- no categorisation -->
|JDOC=<!-- no categorisation -->
|Category=<!-- no categorisation -->
|#default={{#arraydefine:cats|{{{1|}}}}} {{#arrayprint:cats||@@@@|[[Category:@@@@|{{PAGENAME}}]]}}{{#arrayreset:cats}}
}}

[view] [edit] [history]

Template-info.pngTemplate documentation

Contents

The template makes category inclusion in other templates easier. It eliminates the need for complicated #switches and #ifeq of NAMESPACE to allow category inclusion in templates without including those categories in certain NAMESPACES such as, the Template and JDOC NAMESPACES.

Functions/Features

Automatic category inclusion in templates.

Stop hand nuvola.svg.png
Warning!

It is possible to use this template directly in articles. Until this warning is removed, it is not recommended.


Usage

Must use the parameter {{{1|}}}

  • A simple call would be to add {{CatInclude|Development,Tutorial,Plugin}} to pages which use a template to add content to a wiki page.
  • A complex template call against a parameter in a template can be used inside a #if, #ifeq or #switch call.
Example
{{#ifeq:{{{foo|}}}|tutorial|{{CatInclude|Development,Tutorial,Plugin}}|[[Category:Foo]]}}
OR
{{#ifeq:{{{foo|}}}|tutorial|{{CatInclude|Development,Tutorial,Plugin}}|{{CatInclude|Development}}}}

Parameters

Parameter Parameter description req./opt.
{{{1}}} categories (in array format, comma separated)
For Example: Development,Tutorial,Plugin
required

Known Issues

None known, please report on this Template's talk page.