Working With MediaWiki
button)
preview
(for the “Show preview” button)
save and continue
(for the “Save and continue” button — this lets users save the page without leaving the form)
changes
(for the “Show changes” button)
summary
(for the “Summary” text field)
minor edit
(for the “This is a minor edit” checkbox)
watch
(for the “Watch this page” checkbox)
cancel
(for the “Cancel” link)
run query
(for the “Run query” button in query forms)
So, for example, the button for “Save page” could be specified with “
{{{standard input|save|label=Save this page}}}
”, which would place the button where it was defined, with the text on the button reading “Save this page”. If no standard input tags are included in the form definition, all six will appear at the bottom of the form, just as they do for regular "Edit" pages. However, if even one such tag is included, then only those inputs which have been included will be displayed, in the order, and with the wikitext, that they appear in in the form definition.
Enabling multiple field values
There are two parser functions defined by Semantic Forms, #arraymap and #arraymaptemplate, that enable holding multiple values within the same field, by applying the same semantic property to each element of a comma- (or otherwise-) delimited list (a comma-delimited list is a piece of text in which distinct values are separated by commas). There is nothing form-specific, or even semantic-specific, about these functions; but they seem to have not been necessary until Semantic Forms was created, which is why they’re stored there. Of these, #arraymap is the more important: it’s used much more frequently, and it’s the one applied automatically within templates by both Special:CreateClass and Special:CreateTemplate when a field is specified to hold a list of values. #arraymaptemplate is useful when the mapping required is too complex for #arraymap.
#arraymap
The generic call for this function is:
{{#arraymap: value
| delimiter | var | formula | new delimiter }}
The function splits the ’value’ by the ’delimiter’, and then, for each one, applies the same mapping that ’formula’ does to ’var’, and finally joins all the values again using the ’new delimiter’. For example, if you have a form that populates the field ’author’, and you want that field to be able to hold multiple values, separated by commas; and you want each value to also be stored with the semantic property “Has author”, you could add the following to the template code, instead of a regular semantic tag:
{{#arraymap:{{{author|}}}|,|x|[[Has author::x]]}}
Essentially this function “maps” the property tag onto each comma-delimited value in the field. (The ’delimiter’ parameter defaults to "," and ’new delimiter’ defaults to ", " (note the extra space) if they are not set.) The user can thus enter all the values on the same line, with or without spaces around the commas. (Note, by the way, that the "x" is used here as an internal variable: if the property name itself contains the letter "x", that will lead to problems, and you should replace the letter "x" with some character or string that does not appear in the property name, like "@@@@".)
The ’new delimiter’ parameter sets the text that’s placed between values in the resulting output. It is optional, and is usually not set, because its default value — a comma plus a space — is generally what’s needed. However, this parameter is useful in certain cases. It’s especially helpful if none of the resulting values are actually displayed, because in that case you wouldn’t want the output to be a string of commas. A common example of that is if the original value holds a list of category names, and each name gets turned into a category tag, but is not actually displayed. To avoid displaying commas in that case, you should set the ’new delimiter’ value equal to a space, using something like " ", the HTML encoding for a space. (Using just "| " at the end won’t work, because the MediaWiki parser will ignore it.) Here is how such a thing would be called:
{{#arraymap:{{{categories|}}}|,|x|[[Category:x]]| }}
If you use the ’CreateTemplate’ or ’CreateClass’ pages to create a template, and you specify that a field that can take more than one value, then an #arraymap call will be automatically added to the generated template.
#arraymaptemplate
There are some kinds of mapping that are complex
Weitere Kostenlose Bücher