BattleTechWiki talk:SemanticMediaWiki

I'll try to spell out as simply as I can how to use Semantic Wiki to create a new sortable table or timeline. I'll try to be thorough without turning this page into a wall of text.

How does Semantic Wiki (results format) Work?[edit]

Semantic Wiki is much larger than just timelines and tables, but I'll just focus on those two things here. Basically how this works is that you have a inquiry on one page that searches the pages of a specific category for certain properties. For example, if I wanted to know the production year of every BattleMech listed on Sarna, I would tell the page to search the pages under the [[Category:BattleMechs]] category and to look for the property [[Production Year::]]. Here's what that would look like:

{{#ask:[[Category:BattleMechs]]
|?Production Year
|format=table
|mainlabel=BattleMech Timetable
|offset=0
|limit=1
}}

which results in:

BattleMech TimetableProduction Year
Adder (Puma)3010
... further results

Additionally, instead of searching the pages of a category, you can tell it to search a specific page for a property. I just have to replace [[Category:BattleMechs]] with [[Archer]] which results in:

BattleMech TimetableProduction Year
Archer2474

That's nice, but why is this useful?[edit]

A wiki like this is very large and a lot of information is repeated on many different pages. There are quite likely a number of pages that have been updated with current information while older information is still displayed on other pages. With this, you simply update the one page specific to the subject matter and that information is automatically updated on every other page that inquires about that property. Also, scrolling timelines are pretty cool.

Creating a Table From Scratch[edit]

The first thing you will decide what information you want to display. I'll use the example of the list of Archons on the Archon pages as an example. The table there lists four main facts about them: Their name, when their reign began & ended, and which Archon they were descended from. Additionally, I will want to create a note column to define what the Lyran realm was called at the time since it has gone through several different changes. So I will need to create 4 properties for the table to look for. You don't create a property for their name. The names of the articles that you add the properties to (which is the same as the name of the Archon) is used to label the lists on the left hand column.

Creating a Property[edit]

To create a property, you simply type it into the search bar and press go. For example, I'll need to create two properties for the start and end of their reign, and a property for their descent. I'll call the first property "Reign Began", so I will type "Property:Reign Began" into the search bar and press go. I will be directed to a link to create a new page. Do so.

Defining Your New Property[edit]

Now you should have a blank page called "Property:Reign Began". Now you need to tell that property what kind of property it is. Possible types include:

  • Page
  • Date
  • Text
  • Number

There are more examples, but these are the most useful ones. For additional property types, visit this page about properties and types.

For the property "Reign Began" I would probably choose to define it as a date. While it won't be a clickable link on the table to the year, I will be able to sort the table by the dates and display their reigns in a scrollable timeline. However, you may decide to to define it as a page so people can click it and go to the page for that given year. But since I am going to define it as a date, I add the following to the page and save it.

[[Has type::date]]

If I had decided to define it as a page instead, I would have added this instead:

[[Has type::page]]

I'll repeat the process for the properties for their reign ending ("Property:Reign Ended"), their descent ("Property:Inherited From"), and notes ("Property:Notes"). I'll also define the "Reign Ended" property as a date ([[Has type::date]]) but I will define the "Inherited From" property as a page([[Has type::Inherited From]]) and the "Name of the Realm" property as a text ([[Has type::Text]]).

Inserting the Property Into the Page[edit]

Adding the properties to the page is fairly straight forward. To add the "Reign Began" property to an Archon page, you simply go to one, Robert Marsden for example and add this line to the page, "[[Reign Began::2340]]". The same is repeated for all the other properties you want to add, "[[Reign Ended::2375]]", "[[Inherited From::Nine Archons]]", and "[[Name of the Realm::Lyran Commonwealth]].

Inserting the Property Into the Page Cleanly and Quickly[edit]

If all you do is just type "[[Reign Began::2340]]", then you have done the minimum necessary to add the property to that page. But you have likely replaced an existing link to the page [[2340]] with the property, and now you can't click that number to go to the page for that year (because that property type is a date instead of a page). So a faster and cleaner way to add the properties to that page will be to use a template that uses hidden text. An example of this is what I did for the timeline on the Red Corsair article. For every planet the Red Corsair attacked, I added hidden text that added the properties I wanted to display on the timeline (check the page for Arc-Royal for example. What I did was use a template.

Using a Template to Add Hidden Properties[edit]

In the interest of keeping you from falling asleep, I won't go into depth about how to create a template. Instead I'll just provide one and people can use it and adjust it to their needs.

On the Template Page[edit]

First I create a template by typing "Template:Archon Timeline" into the search bar and pressing "Go". I'm prompted to create a new page. I add the following to that page and press save:

<span style="color: red; display:none; font-size: 0px;">[[Reign Began::{{{began}}}]][[Reign Ended::{{{ended}}}]][[Inherited From::{{{inherited}}}]][[Name of the Realm::{{{realm}}}]]</span>

Notice the "font-size" is 0px. This is why the text will be hidden on pages you use this template on.

On the Article Page[edit]

Now to use this template an article page, you use the following code:

{{Archon Timeline
|began=
|ended=
|inherited=
|realm=
}}

Notice each line corresponds to a space in the template ("|began=" and "{{{began}}}" for example)?

So instead of adding "[[Reign Began::2340]]", "[[Reign Ended::2375]]", "[[Inherited From::Nine Archons]]", and "[[Name of the Realm::Lyran Commonwealth]] to the Robert Mardsen page, I would add this instead:

{{Archon Timeline
|began=2340
|ended=2375
|inherited=Nine Archons
|realm=Lyran Commonwealth
}}

You can simply paste the empty template onto each Archon page and quickly add the information instead of hunting in the paragraphs where you can hide the properties. It's much faster, trust me.

Creating the Semantic Table[edit]

Now that that you have added all the properties to each of the Archon articles, you are ready to create your table. You're query will look like this.

{{#ask:[[Category:Archons]]
|?Reign Began
|?Reign Ended
|?Inherited From
|?Name of the Realm
|sort=Reign Began
|order=ascending
|format=table
|mainlabel=Archons of the Lyran Realm
}}

I'll explain it line by line:

{{#ask:[[Category:Archons]]

tells the table to look for your properties in the pages listed under the [[Category:Archon]].

|?Reign Began
|?Reign Ended
|?Inherited From
|?Name of the Realm

Tells it what properties to look for.

|sort=Reign Began
|order=ascending

tell it to sort the results in the order of when their reign began instead of listing the Archons in alphabetical order which is the default setting. You can set the order to "ascending" to list the first Archon at the top or "descending" to list the most recent Archon at the top.

<|format=table

|mainlabel=Archons of the Lyran RealmTwo possible formats for the table are "table" that will keep the table as narrow as possible and "broadtable" which will tell the table to be as wide as your screen permits. The "mainlabel" is the name of your table at the top.

Timeline[edit]

Since you have date properties in your articles, it is possible to plot their reigns on a timeline like the one found on the Red Corsair and Sandbox page. Articles that have a single date will appear as a single dot on the timeline like in the Red Corsair page and articles with two date properties will appear as an event line like on the Sandbox page. The code used to display a timeline instead of table is very similar with only a few lines changed.

{{#ask:[[Category:Archons]]
|?Reign Began
|?Reign Ended
|?Inherited From
|?Name of the Realm
|format=timeline
|timelineposition=middle
|timelinebands=DECADE
|timelinesize=150px
}}
|format=timeline

You change the format to "timeline" instead of "table" or "broadtable". Also "eventline" is very similar to "timeline" but it gives a dot for the beginning and ending date property instead of a solid line for the duration of the event. Also it has colors.

|timelineposition=middle

This tells the timeline to display in the middle of the years displayed. Other settings include "start", "end", and "today" (I don't recommend ever using "today" since everything that happens in Battletech is centuries into our future.

|timelinebands=DECADE

This tells the timeline which date bands to use. "Decade" is the largest band available and best used for timelines that cover several decades or more. This is the setting used on the Sandbox page. Additional settings include YEAR, MONTH, WEEK, and DAY. You can use several bands like on the Red Corsair page, just be sure to list them from smaller increments to larger ones.

|timelinesize=150px

This defines how tall your timeline will be. By default it is 300px tall, but unless you have many events happening at the same time, 150px is plenty enough.

Refresh Tab Button[edit]

Any changes to make to properties on your article pages, like changing a year for example, will automatically be updated on the table or timelines, but they take time to do so on their own. If you want to force it to update immediately, click the "Refresh" tab button (not your browsers refresh button) near the top of the page next to the "edit" and "watch" buttons.

Additional Resources[edit]

I'm happy to answer any questions you all might have or help out with a project. But I'm far from a subject matter expert. Here a few resources I've used to learn what I know.--Seth 22:22, 17 March 2012 (PDT)