Bücher online kostenlos Kostenlos Online Lesen
Working With MediaWiki

Working With MediaWiki

Titel: Working With MediaWiki Kostenlos Bücher Online Lesen
Autoren: Yaron Koren
Vom Netzwerk:
they wouldn’t make sense in this case.) We’ll get to property types in the next section.
    Semantic MediaWiki offers another way to store data, and that’s the #set parser function. Here’s how it would be called for this case:
{{#set:Has capital=Ottawa}}
    In the case of #set, nothing is shown on the screen: #set works “silently”, and stores data without displaying anything. There are various cases in which you may want to store a value without displaying it, and #set is ideal for those cases.

Defining properties
    Every property in Semantic MediaWiki has a type. The type of a property dictates how that property’s values are displayed on the page, how its values are displayed and handled elsewhere, and what kind of values are allowed for that property. By default, properties are of type Page, though it’s good to always define the type explicitly.
    How is a property’s type defined? With yet more semantic annotation. Every property has its own page on the wiki, in the “Property” namespace (or whatever the corresponding name is in the wiki’s language). So the page for the “Has capital” property would be named “Property:Has capital”. In that page, you could add the following:
[[Has type::Page]]
    This would define the “Has capital” property to be of type Page. “Has type” is what’s known as a “special property”: a property that’s pre-defined in SMW with special meaning.
    You could also define the property to be a simple string of characters, by adding the following instead:
[[Has type::String]]
    There are various other standard types defined in SMW. The current full set is: Page, String, Text, Number, Boolean, Date, URL, Email, Telephone number, Code, Quantity and Temperature. Most of these are (hopefully) obvious from their name:
“Page”, as noted before, holds the name of a wiki page.
“String” and “Text” both hold text values; the differences are that “String” can hold only up to 255 characters, while “Text” can hold an unlimited number, and “Text” properties cannot be queried on (though they can both be displayed in queries). It should be noted that in future versions of SMW, starting with SMW 1.8.1, it is planned that these two types will become a single type, that can hold an unlimited number of characters but can also be queried on.
“Number” can hold any integer or decimal number.
“Boolean” can take in any of a number of values meaning “true” and “false”: “yes” and “no” are allowed, as well as values specific to the language of the wiki.
“Date”, “URL”, “Email” and “Telephone number” hold the information that you’d expect them to hold, and are displayed (and linked) appropriately.
“Code” is a minor type that’s basically the same as “Text”, but meant to be displayed in a pre-formatted way.
    “Temperature” and “Quantity” are covered in an upcoming section, “Custom units”.
    There’s also another property type, “Record”, but it’s obsolete, and is best ignored.
Setting allowed values
    There are also properties for which you may want to predefine a set of allowed values; in programming terms, these are usually known as "enumerations". These can be defined in SMW as well, though not with a special type: rather, each allowed value is specified on the property’s page, using the "Allows value" special property. For instance, if we wanted to define a property called "Has day of week", we might add the following to its page:
The allowed values for this property are:
* [[Allows value::Sunday]]
* [[Allows value::Monday]]
* [[Allows value::Tuesday]]
* [[Allows value::Wednesday]]
* [[Allows value::Thursday]]
* [[Allows value::Friday]]
* [[Allows value::Saturday]]
    Enumerations can be of any type, although in practice, they’re almost always either of type Page or String.
Creating property pages
    You can of course hand-create any property page. The easiest way to create properties, though, is via the extension Semantic Forms (see here ). If you have Semantic Forms installed, then going to any uncreated property page should show a “create with form” tab near the “create” tab, which brings you to a form that just needs to be filled out and saved. You can also use either the Special:CreateProperty or the Special:CreateClass pages, both defined by Semantic Forms as well.
Custom units
    You can also define properties that are stored in units — for weight, distance, energy and so on. These can

Weitere Kostenlose Bücher