Help:Subobjects and queries

Subobjects and queries
Explains how to query for a subobject.
Table of Contents

This help page describes how to query for a subobject after they were added to your wiki.

Show all subobjects of a page[edit]

Using #subobject does not print out anything on the screen. Sometimes one would like to show the subobject data directly on the page where it is defined. This can be achieved with the ask query {{#ask: [[-Has subobject::{{FULLPAGENAME}}]] }} which is added after the definition of subobjects.

Defining two subobjects with identifiers "first" and "second":



Then to print out the subobjects one would insert this code on the same page:

 [[-Has subobject::{{FULLPAGENAME}}]] 

Note the "-" which is necessary to make the query work (see Inverse properties for more information).

Show properties of a subobject's parent page[edit]

In some cases one might not only want to query for subobject data but also for "usual" properties that are defined on the subobject's parent page. The process to do that contains the following steps:

  1. Query for a property of a subobject.
  2. Use format=template.
  3. Add another query in this template where you ask for [[Has subobject::{{{1}}}]]. Has subobject returns the parent page of a subobject. The subobject is queried in the first query and passed on to the template as {{{1}}}.

In Template:YourTemplate one adds the following:

 [[Has subobject::{{{1}}}]]

Examples/Queries/Use subobject with template

Searching for pages with certain subobject properties[edit]

When you want to query for (parent) pages that have certain subobject properties, you can use subqueries:

 [[Has subobject::<q>[[YourSubobjectProperty::Foo]]</q>]]

This works, because with the query [[Has subobject::]] (without the "-"), you are querying for the (parent) pages that have subpropeties. With the subquery, you can then select certain subobject properties. As you are queryinig for parent pages, you can select properties of the parent pages as printouts.

See also[edit]