Showing source for Page Queries
ProWiki
|
RecentChanges
|
Preferences
<b>Previous:</b> [[Property Queries]] First, let's look at the Page Query. This is a simple syntax that lets you show all of the pages matching some given criteria. <h3>Page Query Syntax</h3> All page queries look more or less like this: {?<i>query</i> : <i>pattern</i>?} In this, the *query* part describes the criteria you're looking for, and the *pattern* says what to print for each page that matches those criteria. <h3>Simple Page Queries</h3> A simple page query just gives the page names and values for each page that includes that property; if you give a property name as the <i>query</i> and omit the <i>pattern</i>, this is what happens. For example, in the previous page, I showed that IndexName pointed to a special page listing all pages that had the IndexName property. What I didn't mention there was that there is actually nothing very special about that page -- it's simply a small page containing a query! That query looks like this: {?IndexName?} And when it is displayed, it shows up like this: {?IndexName?} In other words, this is a Page Query, listing all pages that define the "IndexName" property. If a page contains multiple values for a property, they are all displayed, separated by vertical bars ('|'). <h3>Patterned Page Queries</h3> Now, let's have a little more fun. Properties start becoming really interesting when you start to relate them together and format them. Remember "IndexAbstract" from the previous page? Here's a way to use it. This query not only shows all pages that have the IndexName property -- it also shows the related IndexAbstract property, and puts the two together. It looks like this: {?IndexName : <b>%%IndexName%%</b> -- %%IndexAbstract%%<br>?} You can describe this query as, "For each page that contains the IndexName property, display the IndexName and IndexAbstract properties on that page, formatted like this". When you display that query, it comes out like this: {?IndexName : <b>%%IndexName%%</b> -- %%IndexAbstract%%<br>?} As you can see, you refer to a property using the syntax %%<i>propname</i>%%. Again, yes, I made it up. Live with it. (Or reimplement using a syntax that suits you better.) <h3>PAGENAME</h3> Each page has an implicit property called PAGENAME. You don't define this explicitly -- it's always there. Notice that the IndexName for the previous page doesn't quite match the actual name of the page. If we wanted to include the real name, we could tweak our query to look like this: {?IndexName : <b>%%IndexName%%</b> (<i>%%PAGENAME%%</i>) -- %%IndexAbstract%%<br>?} When displayed, this comes out as: {?IndexName : <b>%%IndexName%%</b> (<i>%%PAGENAME%%</i>) -- %%IndexAbstract%%<br>?} Note that PAGENAME references are always displayed as links. <b>Next:</b> [[Property Lists]]