Extension:Page Forms/Example

Let's go through a specific example of setting up a Semantic Forms-based wiki from scratch. Let's say that you want to create a wiki that shows all the books you have at home. For the purpose of this example, we'll say that your wiki uses version 1.0 of Semantic MediaWiki, plus the latest version of Semantic Forms. We'll then go through the steps specified in "Getting started".

Figure out the data structure. You want two kinds of pages on your wiki: one for books, and one for authors. Each book page should hold a title, an author name, a genre (or genres), a year of publication, and a number of pages. Each author page should hold the author name, their country of origin, and a list of all the books they have written that you own.

Create properties. For books, there is no need to create a property for the title, since the title of each page representing a book will be the title of that book. That leaves four fields:
 * Author - using the "Create a property" page, you create a property called "Was written by", of type "Page" (since each author will have his/her own page).
 * Genre - you create a property called "Has genre", of type "String", and give it the following allowed values: "Art, Cookbook, Fiction, History, Poetry, Science".
 * Year of publication - you create a property called "Was published in year", of type "Number".
 * Number of pages - you create a property called "Has number of pages", of type "Number".

For author pages, you only need to create one more property:


 * Country of origin - you create a property called "Is from country", of type "String".

Create templates. You need to create two templates, one for books and one for authors:
 * Books - using the "Create a template" page, you create a template called "Book", and set it to define the category "Books". You add to it four semantic fields: "Was written by" (to which you give the field name and label "Author"), "Has genre" (to which you give the field name and label "Genre"), "Was published in year" (to which you give the field name "Year" and the label "Year of publication"), and "Has number of pages" (to which you give the field name and label "Number of pages"). For the "Genre" field, you also check the box saying that the field can hold a list of values, since you want to be able to select more than one genre for a given book.
 * Authors - using the "Create a template" page, you create a template called "Author", and set it to define the category "Authors". You add to it the semantic field "Is from country", to which you give the field name "Country" and the label "Country of origin". For this template, you also fill out the "aggregation" fields in the form, since you want each author page to list all the books the author has written by. Under "Semantic property", you select "Was written by", and for "Title for list" you put "Books by this author".

Create forms. You need to create two forms, one for books and one for authors:
 * Books - using the "Create a form" page, you make a form called "Book", and add to it the template "Book". You do not do any further customizations on this form, but just save the form once you have created it.
 * Authors - using the "Create a form" page, you make a form called "Author", and add to it the template "Author". As before, you do not do any further customizations - you just save the page.

Create categories. You need to create two categories, one for books and one for authors; you have already specified these categories' names before:
 * Books - using the "Create a category" page, you make a category called "Books", and give it the default form "Book".
 * Authors - using the "Create a category" page, you make a category called "Authors", and give it the default form "Author".

Enable links to forms. In your installation of MediaWiki, you enable red-links pointing to forms, using the code change found here. You then manually add the text "This property uses the form Has default form::Form:Author." to the "Was written by" property's page.

Add data. Using the new "Book" form, you create pages for some books; you check to make sure that both the form and the resulting pages look alright. Each book page will now have a red link to its author, that should point to the "Author" form for adding that author (you may need to refresh the page for the right link to show up). You can then add a few authors, either through these links or on the form page directly, to make sure that this setup works correctly too. Each created author's page should show a list of the books you've saved that have that person as the author.

Add links on sidebar and elsewhere. Your structures are now all set up, and you can add links to the sidebar for easy adding and viewing. You can add links to the "Book" and "Author" forms to make it easy to add new ones, and links to the "Books" and "Authors" categories to be able to see the full list of either one at a glance.