Besides content that is already available on a specific ContentType listing-
page or single-page (Record and Records), you can
directly fetch content from the database. For this you can use the
{% setcontent ... %} tag. The following example will get the content record
with slug 'about' from the 'pages' ContentType:

{% setcontent about = 'page/about' %}
{{ dump(about) }}

There are a lot of options for the setcontent tag. Most are optional, and all
can be used together any way you'd like. The most basic syntax is:

{% setcontent _variable_ = '_contenttype_' %}

This will set a variable to contain the records of the given contenttype.
For example: {% setcontent mypages = 'pages' %} will set {{ mypages }} to
an array of all the records in 'pages'.

Normally, you don't need all records, but a subset of the available records.
You can limit the number of records by using a where clause (more on that
below), but often it's easier to use the shortcut that Bolt provides.

If you need a single record, and know its id or slug, you can do this:

The above examples selected records based on the parameter being equal to
the matching field in the available records. It's also possible to use
modifiers for the values, to select based on 'smaller than' or 'does not
equal':

Tip: When using 'where' statements with a field
that is a date, you can use relative, textual dates, like 'last monday'
or '> this year'. Internally, Bolt uses the
strtotime() funtion for this, so we refer to its
manual page for details.

Like mentioned above, you can add more than one parameter to the where
clause:

{# get all pages not created by 'pete', and created after july 2012, with a .jpg image #}
{% setcontent mypages = 'pages' where { ownerid: '!3', datecreated: '>2012-07-31', image: '%.jpg%' } %}

You can use the && and ||-parameters to select on two criteria for any
field. However, you can't use something like where { ownerid: '!3', ownerid: '!4'} because of the way hashes work in twig: The second ownerid would
overwrite the first. Instead, you can use the && and ||-parameters to
either select using AND or OR. examples:

As you might've noticed, in the examples above, we've used ownerid a couple
of times to get content specific to a given user. In Bolt, content is stored
with a reference to the owner, the so called ownerid. This means that you
cannot do things like this:

The results can be sorted by any of the fields of the ContentType, using the
orderby clause. You can sort either ascending or descending. The order is
determined by the inclusion (or omission) of the minus before the name of
the field: title vs. -title.

If you're working on selecting some content, but aren't quite getting the
desired results, you can add printquery to the {% setcontent %}- tag. Doing
this will output the SQL query Bolt creates and executes. For example: