Template:Get Element Types: Difference between revisions
Jump to navigation
Jump to search
(start) |
(updated search and explanation) |
||
Line 1: | Line 1: | ||
<noinclude> | <noinclude> | ||
[[Category:Templates]] | [[Category:Templates]] | ||
This template only serves to find all element types for a given page. It is called with only one parameter: | This template only serves to find all element types for a given page - it doesn't print them. It is called with only one parameter ''page'': | ||
<pre><nowiki> | <pre><nowiki> | ||
{{Get Element Types|page=}}</nowiki></pre> | {{Get Element Types|page=}}</nowiki></pre> | ||
After calling this template, there exist two arrays (using [http://www.mediawiki.org/wiki/Extension:ArrayExtension extension ArrayExtension]): | After calling this template, there exist two arrays (using [http://www.mediawiki.org/wiki/Extension:ArrayExtension extension ArrayExtension]): | ||
* Array "Cats", containing all categories that ''page'' is a member of | * Array "Cats", containing all categories that ''page'' is a member of; | ||
* Array "ElementTypes", containing the types of element that the ''page'' is a member of (stripped of the prefix "Element type" | * Array "ElementTypes", containing the types of element that the ''page'' is a member of (stripped of the prefix "Element type") | ||
Thus, if page ''EL.Example'' is a member of categories ''FooBar, Element type foo, Element type bar'', then<br> | Thus, if page ''EL.Example'' is a member of categories ''FooBar, Element type foo, Element type bar'', then<br> | ||
Cats=''FooBar, Element type foo, Element type bar''<br> | Cats=''FooBar,Element type foo,Element type bar''<br> | ||
ElementTypes=''foo, bar'' | ElementTypes=''foo,bar'' | ||
After calling this template, you can access the categories and Element Types using the [http://www.mediawiki.org/wiki/Extension:ArrayExtension#arrayprint #arrayprint] function. An example that creates a pretty, comma delimited list: | |||
<pre><nowiki>{{#arrayprint:ElementTypes||@ |@ |print=pretty}}</nowiki></pre> | |||
---- | ---- | ||
</noinclude><includeonly>{{#arraydefine:Cats|{{ | </noinclude><includeonly>{{#arraydefine:Cats|{{ShowCategories|page={{{page}}}}}|,|unique}}{{#arraysearcharray:ElementTypes|Cats|/^Element\stype\s/|0|-1|{{#sub:$0|13}}}} |
Latest revision as of 11:55, 29 December 2012
This template only serves to find all element types for a given page - it doesn't print them. It is called with only one parameter page:
{{Get Element Types|page=}}
After calling this template, there exist two arrays (using extension ArrayExtension):
- Array "Cats", containing all categories that page is a member of;
- Array "ElementTypes", containing the types of element that the page is a member of (stripped of the prefix "Element type")
Thus, if page EL.Example is a member of categories FooBar, Element type foo, Element type bar, then
Cats=FooBar,Element type foo,Element type bar
ElementTypes=foo,bar
After calling this template, you can access the categories and Element Types using the #arrayprint function. An example that creates a pretty, comma delimited list:
{{#arrayprint:ElementTypes||@ |@ |print=pretty}}