Page Forms: Difference between revisions
m (using an external editor) |
|||
Line 140: | Line 140: | ||
Add: | Add: | ||
<nowiki>[[Has default form:: | <nowiki>[[Has default form::your_form-name_here]]</nowiki> | ||
Example: | Example: | ||
=== Pointing red links to an appropriate form === | === Pointing red links to an appropriate form === |
Revision as of 17:02, 26 August 2011
This article or section is currently under construction
In principle, someone is working on it and there should be a better version in a not so distant future.
If you want to modify this page, please discuss it with the person working on it (see the "history")
Don't trust anything yet - Daniel K. Schneider 18:01, 26 August 2011 (CEST) !!!
Introduction
Semantic Forms is an Mediawiki extension for the Semantic MediaWiki extension.
Semantic Forms is an extension to MediaWiki that allows users to add, edit and query data using forms. It is heavily tied in with the Semantic MediaWiki extension, and is meant to be used for structured data that has semantic markup. Having Semantic MediaWiki installed is a precondition for the Semantic Forms extension; the code will not work without it (and you must have version 1.4 or higher of SMW).
Very simply, Semantic Forms allows you to have forms for adding, editing and querying data on your wiki, without any programming. Forms can be created and edited not just by administrators, but by users themselves.
The main components of Semantic Forms functionality are form definition pages, which exist in a new namespace, 'Form:'. These are pages consisting of markup code which gets parsed when a user goes to add or edit data. Since forms are defined strictly through these definition pages, users can themselves create and edit forms, without the need for any actual programming.
(Extension:Semantic Forms, retrieved 13:30, 25 August 2011 (CEST))The semantic forms extension is very complex and requires a bit of technical background in both knowledge representation and markup languages. However, a few special pages can help with creation of various items needed to define a form and the underlying semantic data structures.
Principles
Workflow for creating a form
A form is usually made for creating object of a given type, i.e. a class. The form itself relies on pre-defined properties and mediawiki templates. Without these, the form won't work !
- Define properties that will represent the data structure of objects. For each property a page in the property: namespace will be created. Thus, properties also can be documented.
- Create templates, one for each object.
- Create forms for creating objects with values
- Create categories, typically one for each form/object
- Enable links to forms
- Add data using forms
The easiest way of creating classes and forms from scratch is using the Special:CreateClass page. It's an all-in-one solution with a form that allows to define property names, associated form field names, property types, allowed valudes and a checkbox for multiple values.
SMW principles
(should be moved to its own page once I get going ...)
Data in Semantic MediaWiki are defined by properties. Each property must be created as a page in the properties namespace. E.g. to create a name property, use:
[[property:: name]]
The easiest way to create such a property page is to use the Special:CreateProperty "special" page.
Properties do have data types, for example
- Page (i.e. the value of the property is a wiki page)
- String (a short text)
- Text (a longer text)
- Code (same but pre-formatted)
- URL
- Number
- Date
- Enumeration
- Boolean
The Form markup language
The markup language used by this extension uses the MediaWiki templates syntax. “Forms are defined using a set of tags that specify templates and fields within those templates. Wiki-text, and some HTML, can be freely embedded anywhere outside of the tags.” (Extension:Semantic Forms, retrieved 25 August 2011)
Forms must be created within the Form: namespace
- Example: Form:Opinion item
A somewhat minimual form definition looks like this:
Example 1
We shall reproduce the example referred to in the Semantic Forms documentation, i.e. the Item defined in the Discourse DB wiki. However, we will make some changes, i.e. make it a bit simpler. In particular, some data just will be strings as opposed to pages.
The example includes 3 classes
- Option item (called just Item in the original). It is defined by the four properties: Author, Was published by, Was published on, Has URL, Has Quote.
- Opinion is defined by three properties:
- Reference
Create properties
The easiest way to create properties is to use the Special:CreateProperty page. Alternatively you just could create a page like [[Property:XXX]]
When you copy forms and templates from other SWM web sites you have to be carefuls understanding what the property names are. Not to be confused with form field names (although they can be the same of course).
So let's create all the properties needed using the Special:CreateProperty page. By default, a property is of type page. In other words if you get a "red link" after filling in a form and you don't want one, it means that you didn't define the property or that your form isn't using the right property.
An Opinion item (called item) in the original is represented by the following properties
Property name Type changes from discourse db Was written by String was Type=page Was published by String was Type=page Was published on Date Has URL URL Has quote Text
An Opinion (simplified, in the original opinions were implemented a subpages of a page representing the topic).
Property name Type changes from discourse db addresses topic Page is for String was Type = Page is against String was Type = Page is mixed on String was Type = Page
A Opinion reference (called reference in the original) links to a prior Opinion item.
Property name Type changes from discourse db refers to Page
Were therefore get this list of properties:
- Property:Addresses topic
- Property:Has URL
- Property:Has quote
- Property:Is against
- Property:Is for
- Property:Is mixed on
- Property:Refers to
- Property:Was published by
- Property:Was published on
- Property:Was written by
Create templates
For each of these classes, a template that defines (part) of its visual layout should now be created.
See:
Create the forms
This example uses two forms. One main form for defining opinion items. And a form that could be used to add references to other items.
Finally, you should create one (or more) forms for editing the data
See:
Edit the category
Add:
[[Has default form::your_form-name_here]]
Example:
Pointing red links to an appropriate form
Example 2
Links
Homepage and download
- Extension:Semantic Forms at mediawiki.org. This page also includes a good manual.
Introductions, manuals
- Extension:Semantic Forms at mediawiki.org. This page also includes a good manual.
- Extension:Semantic Forms/Example (learning by example)
- SMW QuickReference. Includes also help for semantic drilldown and external data.
Examples sites using this extension
- Gardenology.org - Plant & Garden Wiki Encyclopedia,
- Discourse DB
- Example of a form at placeography.org
- Discourse DB
- Create an opinion item
- Magazine template
- Magazines Category. It shows how to define a default form for a category.
- Newsweek Magazine entry