@query

Queries for nodes and makes those nodes available to the template.

Parameters

parameter required description
type the type of node to query for (definition QName)
sort the field to sort on
sortDirection the direction to sort in (either 1 for ascending or -1 for descending)
limit the number of records to return
skip a position to skip ahead to in the record set
scope if "page", then only relatives related to the current page will be returned
as specifies the name of the resultsvariable (by default - rows)
field the name of a property to match against)
fieldRegex the match to run against the field)
fieldValue the fixed value to check against the field)
near geolocation coordinates to query around
locale the locale to use in retrieving content

Response

The result is an associative array of key/value pairs for each of your nodes. Each key is the resulting node ID and each value is the JSON for the node.

Examples

Example #1: Restaurant Names

Here is an example where we retrieve nodes of type custom:restaurant. We use this to build out a table. Each row of the table shows the restaurant's node ID and title.

{@query sort="title" skip="0" limit="5" type="custom:restaurant"}
   <table>
   {#rows}
      <tr>
         <td>{_doc}</td>
         <td>{title}</td>
      </tr>
   {/rows}
   </table>
{/query}

Example #2: Restaurant List with Thumbnail Images

Here is an example that lists restaurants and shows an thumbnail image for each:

{@query sort="title" skip="0" limit="5" type="custom:restaurant"}
   <table>
   {#rows}
      <tr>
         <td>
            {#attachments.default}
            <img src="{preview64}">
            {/#attachments.default}
         </td>
         <td>{title}</td>
      </tr>
   {/rows}
   </table>
{/query}

Example #3: Restaurants near Boston

Here is an example where we retrieve nodes of type custom:restaurant that are near a specific geographic location - that of Boston, Massachusetts.

Each row of the table shows the restaurant's node ID and title.

{@query sort="title" skip="0" limit="5" type="custom:restaurant" near="42.3584308,-71.0597732"}
   <table>
   {#rows}
      <tr>
         <td>{_doc}</td>
         <td>{title}</td>
      </tr>
   {/rows}
   </table>
{/query}