Working With MediaWiki
values the user entered.
The "Run query" button
By default, a button called "Run query" shows up at the bottom of forms if they are accessed via Special:RunQuery. You can change the location and text of this button, using the tag "
{{{standard input|run query}}}
" (or "
{{{standard input|run query|label=...}}}
", etc.) within the form definition.
Query form at top
If you add the parameter "
query form at top
" to the
{{{info}}}
tag, the query input field will show up at the top of the results page, instead of the bottom.
Creating links to query forms
Once a query form has been created, you can link to it using syntax that looks like this:
[[Special:RunQuery/]]
However, the preferred solution, because it’s easier and more powerful, is to use the #queryformlink parser function. A basic call to that function would look like:
{{#queryformlink:form=}}
Here’s the complete syntax of #queryformlink:
{{#queryformlink:form= |link text= |link type= |query string= |query string parameters |tooltip= |popup}}
These parameters are almost identical to the ones used by #formlink ( see here ).
Embedding query forms
You can also embed a query form within another page. To do that, add the following in a page where you want the query form to appear:
{{Special:RunQuery/}}
Semantic Forms Inputs
Semantic Forms Inputs (SFI) is a helper extension for Semantic Form: it serves as a container for additional input types that are less essential, though still useful. The current input types defined in SFI are:
datepicker — provides a JavaScript-based input for picking dates using a mini-calendar, of the kind seen often on the web. It looks like this:
datetimepicker — like datepicker, but includes a time input.
regex — a regular text input that can include custom validation rules, using a “regular expression” — useful for, for instance, a phone number input (a regular expression is a piece of syntax that is used to find matches in strings).
menuselect — displays a set of text values as a hierarchical menu of options. Users can choose any element in the hierarchy. Here is an example, for a clothing item field:
two listboxes — a multi-select tool that lets uses move items between a “selected” and an “unselected” listbox.
18 Displaying data
This chapter covers the ways in which data can be displayed and visualized within MediaWiki. With the exception of the Maps and DynamicPageList extensions, all the options in this chapter depend on Semantic MediaWiki. There are non-SMW-based data display tools for MediaWiki — there are a number of calendar extensions, for instance — but these are almost always hacks to some degree, since they don’t rely on data in any kind of standardized format. If you want calendars, charts and maps on your wiki, the Semantic MediaWiki approach is the most flexible, and the easiest one to maintain.
Calendars
Figure 18.1 Calendar created with the ’calendar’ format
After maps, calendars may be the second-most-common form of data visualization. The ’calendar’ format for SMW queries, defined in Semantic Result Formats, lets you display date-based data in a monthly calendar. Here’s an example of a call to display a calendar:
{{#ask:[[Category:Meetings]]
|? Has date
|format=calendar
}}
This will display a calendar that could look like the one in Figure 18.1.
The navigation at the top lets the user move to other months; the current month being displayed is set in the URL’s query string.
There’s an inefficiency at the heart of the Calendar format: unlike other formats, it doesn’t stop querying after it gets a certain number of results. Instead, it goes through every result, in order to get all the ones that apply to the current month. If there are thousands of dates, or more, this could potentially slow down the system. Unfortunately, the Calendar format can’t query on only the dates within the specified month, because of how SMW works: all the querying is done before the format code kicks in. But there’s a workaround you can do — just change the query to look like the following:
{{#ask:[[Category:Meetings]]
[[Has date::>{{#calendarstartdate:}}]] [[Has date::<{{#calendarenddate:}}]]
|? Has date
|format=calendar
}}
#calendarstartdate and #calendarenddate are parser functions, defined by the Calendar format, that simply display the first and last dates of the month that the user is currently looking at. This
Weitere Kostenlose Bücher