@queryOne

Supports all of the same mechanics as the @query tag but keeps only the first result.

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
fields comma separated list of property names to include in query results
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 results variable (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 a single content item. If multiple items are found in the query results, the first item is kept and it
is passed to the template.
is the JSON for the node.

Examples

Example #1: Single Restaurant

{@queryOne sort="title" skip="0" limit="5" type="custom:restaurant"}
   <div>
      <h3>@queryOne</h3>
      <p></p>
   </div>
{/queryOne}

Example #2: Single Restaurant with Thumbnail Image

{@queryOne sort="title" skip="0" limit="5" type="custom:restaurant"}
   <div>
      <h3>@queryOne</h3>
      <p></p>
      
      {#attachments.default}
         <img src="{preview64}">
      {/#attachments.default}
            
   </div>
{/queryOne}

Example #3: Single Restaurant (with Caching)

This example uses the cache parameter to cache the resulting HTML so that additional requests will render much
more quickly (by avoiding the need to go over the wire to the API at all).

{@queryOne sort="title" skip="0" limit="5" type="custom:restaurant" cache="true"}
   <div>
      <h3>@queryOne</h3>
      <p></p>
   </div>
{/queryOne}