Manual:Extension/Page Forms/Snippets and Template:ButtonLink: Difference between pages

(Difference between pages)
No edit summary
 
(Autogenerated)
 
Line 1: Line 1:
== Providing input values from a (sub-) category ==
<noinclude>Inspired by https://www.mediawiki.org/wiki/Template:Clickable_button_2
=== Using input type "tree" ===
</noinclude><includeonly><div>{{#ifeq:{{#switch: {{{external}}}|yes|ja=yes}} |yes|<span class="plainlinks">[{{{target}}} <span role="button" class="mw-ui-button {{#switch: {{{format}}}|blue|blau=mw-ui-progressive|red|rot=mw-ui-destructive|}}">{{{label}}}</span>]</span>|[[{{{target}}}|<span role="button" class="mw-ui-button {{#switch: {{{format}}}|blue|blau=mw-ui-progressive|red|rot=mw-ui-destructive|}}">{{{label}}}</span>]]}}</div></includeonly>
(see official documentation: [[mediawikiwiki:Extension:Page_Forms/Input_types#tree|mediawiki.org/wiki/Extension:Page_Forms/Input_types#tree]]  )<syntaxhighlight lang="text">
<noinclude>
{{{field|doctype|input type=tree|top category=Document type|depth=1|hideroot|list}}}
<templatedata>
</syntaxhighlight>Form display:
{
[[File:PF tree.png|alt=screenshot of category tree with one value selected|none|thumb|Field type tree]]
"params": {
 
"external": {
 
"label": {
Example output of template parameter:  <code>doctype=Process</code>
"en": "Is this an external link?",
 
"de": "Ist dies ein externer Link?"
=== Using DPL query (dropdown) ===
},
(Solution found at: https://www.mediawiki.org/wiki/Extension_talk:DynamicPageList3#Return_page_titles_as_plain_text?<syntaxhighlight lang="text">
"description": {
{{{field
"en": "Link needs to start with http:// or https://",
| doctype
"de": "Ein externer Link beginnt mit http:// oder https://"
| input type=dropdown
},
| values = {{#dpl: namespace = Category
"example": {
| category = Document type
"en": "no, yes",
| mode = inline
"de": "ja, nein"
| format = ,¶%TITLE%,,
},
| inlinetext = ,
"default": {
  }}
"en": "no",
}}}
"de": "nein"
</syntaxhighlight>Form field:
},
[[File:PF-subcat-dpl.png|alt=screenshot of the dropdown result for the dpl3 solution|none|thumb|values provided by dpl3 parser function]]
"type": "boolean",
 
"suggested": true
 
},
Example template output:
"target": {
 
"label": {
<code>doctype=Process</code>
"en": "Link target",
 
"de": "Zielseite"
 
},
Using an SMW inline query
"required": true
 
},
<syntaxhighlight lang="text">
"label": {
{{{field|doctype|input type=dropdown|values={{#ask: [[Subcategory of::Document type]]|format=plainlist|sep=,|link=none|template=SMW Pagename}} }}}
"label": {
</syntaxhighlight>The above example uses the mapping template  ''Template:SMW Pagename'' to avoid showing the namespace prefix "Category:" in the dropdown. Create the template with the following content:<syntaxhighlight lang="text">
"en": "Label ",
{{PAGENAME:{{{1|}}} }}
"de": "Bezeichnung"
</syntaxhighlight>Although the category prefix is then not shown in the dropdown, the value the form passes to its associated template parameter still includes the namespace prefix.
},
 
"required": true
Example template output:
},
 
"format": {
<code>doctype=Process</code>
"label": {
=== Using an SMW concept ===
"en": "Background color (leave empty for white)",
Create the page Concept:Doctype with the following content:<syntaxhighlight lang="text">
"de": "Hintergrundfarbe (für weiß leer lassen)"
{{#concept:
},
[[Subcategory of::Documenttype]][[Modification date::+]]
"example": {
|List of sub categories of the category Documenttype
"en": "blue, red",
}}
"de": "rot, blau"
</syntaxhighlight>Use this concept as the source for the values of your field:<syntaxhighlight lang="text">
},
{{{field|doctype|input type=dropdown|values from concept=doctype|mapping template=catConcept}}}
"suggested": true
</syntaxhighlight>The above example uses the mapping template  ''Template:catConcept'' to avoid showing the namespace prefix "Category:" in the dropdown. Create the template with the following content:<syntaxhighlight lang="text">
}
{{PAGENAME:{{{1|}}} }}
},
</syntaxhighlight>Although the category prefix is then not shown in the dropdown, the value the form passes to its associated template parameter still includes the namespace prefix.
"description": {
 
"en": "Styles a text link as button",
Example template output:
"de": "Formatiert einen Textlink als Button."
 
}
<code>doctype=Category:Process</code>
}
</templatedata>
</noinclude>

Revision as of 15:47, 15 June 2023

Inspired by https://www.mediawiki.org/wiki/Template:Clickable_button_2


Styles a text link as button

Template parameters

ParameterDescriptionTypeStatus
Is this an external link?external

Link needs to start with http:// or https://

Default
no
Example
no, yes
Booleansuggested
Link targettarget

no description

Unknownrequired
Label label

no description

Unknownrequired
Background color (leave empty for white)format

no description

Example
blue, red
Unknownsuggested




To submit feedback about this documentation, visit our community forum.

No categories assignedEdit

Discussions