Advanced Page Queries

ProWiki | RecentChanges | Preferences

Showing revision 6
Previous: Inheritance

Okay -- now that we've laid out the groundwork, let's talk about some of the more advanced features of the query language.

Inheritance Queries

One of the most useful kinds of query is the inheritance query. This is a special kind of page query, that says, "Show me all the pages that descend from this type". An inheritance query looks just like any other page query, except for one major tweak: you put a "~" in front of the query string, to indicate that you are looking for inheritance instead of properties.

For example, let's look at The Incredibly Dippy Subway Game. This contains many characters of different classes -- that is, each character has an IS_A property that points to the character's class. One of those classes is "Loiterers". To list all of the Loiterers in the game, you give this query:

{?~Loiterer : <b>%%Name%%</b> (<i>%%PAGENAME%%</i>)<br>?}

That is, "For each page that inherits from Loiterer, show me the Name and PAGENAME of that page." It shows up like this:

A bag lady (Bag Lady)
Guy With a Guitar (GuitarGuy)
A skateboard punk (Skateboard Punk)

This is one of the most powerful queries in ProWiki, because it lets you make lists of objects very easily. If most of the pages in your Wiki are typed objects, then it's trivial to make pages that list them in all sorts of different ways.

Combining Query Clauses

Now let's make that even more powerful. All of the page queries shown so far simply give a single "word" as the query string. But in fact, ProWiki allows you to combine multiple query clauses to get more refined queries.

The best way to understand this is to think of a query as reading from left to right. Each clause defines a set of pages, which are then combined using conjunctions to get the final result. There are three kinds of conjunctions available:

For a simple example, let's look at the Subway Game again. There are two major kinds of Characters in the game, Passengers and Loiterers. But there are a few Characters who don't fall into either of those categories. To list just the Characters who are neither Passengers nor Loiterers, we would say:

Musician (Musician)
A security guard (Security Guard)

 

Nesting Property Lists Inside Page Queries


ProWiki | RecentChanges | Preferences
This page is read-only | View other revisions | View source of this page | View current revision
Edited May 19, 2005 6:10 pm by Jducoeur
Search:
Edit: