Difference between revisions of "WikiDB/Tutorial"

From TestWiki
Jump to: navigation, search
(step 2 - Table:Companies2)
(Step 3)
Line 1: Line 1:
== Step #1 - Defining Data ==
+
== Step 1 - Defining Data ==
  
 
Suppose you have a standard infobox, say [[Template:Infobox company]].  You use it in a page by entering the following syntax:
 
Suppose you have a standard infobox, say [[Template:Infobox company]].  You use it in a page by entering the following syntax:
Line 43: Line 43:
 
Now, take a look at [[Table:Companies]] and you can see the above data in tabular form.
 
Now, take a look at [[Table:Companies]] and you can see the above data in tabular form.
  
== Step #2 - Defining A Table ==
+
== Step 2 - Defining A Table ==
  
 
Now we are going to try setting up a table definition, using the following data:
 
Now we are going to try setting up a table definition, using the following data:
Line 68: Line 68:
  
 
Take a look at the definition at [[Table:Companies2]].  You can see that the defined fields and undefined fields are separated out, and that data is modified according to the field definitions.  This does not affect the data on this page, but it does affect how it is displayed within the wiki.  Changing the table definition has immediate effect though, in the standard wiki way this can be, and of course can always be reverted if there are problems.
 
Take a look at the definition at [[Table:Companies2]].  You can see that the defined fields and undefined fields are separated out, and that data is modified according to the field definitions.  This does not affect the data on this page, but it does affect how it is displayed within the wiki.  Changing the table definition has immediate effect though, in the standard wiki way this can be, and of course can always be reverted if there are problems.
 +
 +
== Step 3 - Fixing errors ==
 +
 +
In the above example, you may have noticed that there were two fields 'Name' and 'Annual revenue' which should have been 'Company name' and 'Revenue' respectively.  In this case you can either go and fix each record, or define aliases for the incorrectly named fields.
 +
 +
<data table="Companies3">
 +
  Company name=Microsoft
 +
  Founded= 1492
 +
  Location=Seattle
 +
  Annual revenue=$8
 +
</data>
 +
 +
<data table="Companies3">
 +
  Founded=April 2005
 +
  Revenue=$7.42
 +
  Company name=Apple
 +
  Logo=Image:Apple logo.png
 +
</data>
 +
 +
<data table="Companies3">
 +
  Name=Intel
 +
  Founded=USA
 +
  Logo=Image:Intel_logo.jpg
 +
</data>
 +
 +
I have defined the same data for [[Table:Companies3]], which has aliases in place.  Take a look and see what a difference it makes.

Revision as of 02:02, 9 July 2006

Step 1 - Defining Data

Suppose you have a standard infobox, say Template:Infobox company. You use it in a page by entering the following syntax:

Microsoft

Year founded: 1492
Annual Revenue: $8

Which gives the following result:

Microsoft

Year founded: 1492
Annual Revenue: $8

In order to add this table to a database, you simply replace the above syntax with the following:

<data table="Companies" template="Infobox company">
name=Microsoft
founded=1492
revenue=$8
</data>

This generates exactly the same output:

Microsoft

Year founded: 1492
Annual Revenue: $8

...BUT it also adds data to the Companies table. There is no definition for this table yet, but the data is there!

Data can be defined on any page in the wiki, and more than one row of data can be defined in a page. You get to group data with content, and still have it displayed in a standard format within the page.

You can omit the template parameter altogether, and the data will be hidden, or you can use the special name "default" to display the data in a standard format, as follows:

name founded revenue
Apple 1984 $7.42


Now, take a look at Table:Companies and you can see the above data in tabular form.

Step 2 - Defining A Table

Now we are going to try setting up a table definition, using the following data:

Company name Logo Founded Location Revenue Annual revenue
Microsof   1492 Seattle   $8


Company name Logo Founded Location Revenue
Apple File:Apple logo.png April 2005   $7.42


Company name Logo Founded Location Revenue Name
  File:Intel logo.jpg USA     Intel


Take a look at the definition at Table:Companies2. You can see that the defined fields and undefined fields are separated out, and that data is modified according to the field definitions. This does not affect the data on this page, but it does affect how it is displayed within the wiki. Changing the table definition has immediate effect though, in the standard wiki way this can be, and of course can always be reverted if there are problems.

Step 3 - Fixing errors

In the above example, you may have noticed that there were two fields 'Name' and 'Annual revenue' which should have been 'Company name' and 'Revenue' respectively. In this case you can either go and fix each record, or define aliases for the incorrectly named fields.




I have defined the same data for Table:Companies3, which has aliases in place. Take a look and see what a difference it makes.