Entities

Entities

{{ entities }}

Name Type Description
is_valid Boolean Returns true if this contains at least one entity
prepended list entities that will be listed at the beginning of the items list
fetched list The primary list of entities to be included in the items list
appended list entities that will be listed at the end of the items list
appended_unique list pages that will be listed at the end of the items list, excluding any pages that are already included in either the prepended or fetched lists
items list The full list of entities in the proper order and uniqueness, including prepended, fetched, and appended entities
size Integer The total number of items in the list of items, including prepended, fetched, and appended entities
limit Integer The maximum number of entities that could have been fetched dynamically from the database
start Integer The 1-based index of the first entity that was (or would have been) dynamically fetched from the database
page Integer The 1-based index of the first "page" of entities that could have been fetched dynamically from the database - as determined by the start and limit properties
total_count Integer The total number of entities in the database that matched the provided filter parameters when fetching the list of fetched entities
total_pages Integer The total number of "pages" of results that matched the provided filter parameters when fetching the list of fetched entities - as determined by the total_count and limit properties
output String The default output that the entities will produce when it is output directly to the template - using the "output_in_list" property of each entity in the items list

Contains a collection of content, including pagination-related information.

{% entities %}

{% entities output_to_template? [var, set, or assign]? variable? output_to_template? = arguments %}

{% entities
output_to_template
 
If included the entities will be output directly to the template.
var, set, or assign
 
Optional. Specify either "var", "set" or "assign" to change which scope this entities is stored on. "var" is the default behavior.
variable
output_to_template
 
If included the entities will be output directly to the template.
=
arguments
 
Key:value pairs. May use the variable arguments syntax.
%}

arguments

prepend
 
May be a single , a list of entities, or the name or guid of a to be be included at the beginning of the entities.
append
 
May be a single , a list of entities, or the name or guid of a to be be included at the end of the entities.
exclude
 
May be a single , a list of entities, or the name or guid of a that should NOT be included in the fetched results. Has no affect on prepended or appended entities.
exclude_prepended
 
True to specifically exclude all prepended entities from the fetched results. If "unique:true" is specified this is the default behavior, although you may also specify "exclude_prepended:false" to allow any prepended items to be fetched along with other results anyway.
exclude_appended
 
True to specifically exclude all appended entities from the fetched results. This is false by default - even if "unique:true" is specified - so that results are returned in the proper order.
unique
 
True to remove duplicates from each of the resulting lists (prepended, fetched, appended, and items), although there may be duplicates between the prepended, fetched, and appended lists. The "items" list will include objects in the order in which they appear - with prepended items first, then fetched items, then appended items.
max_size
 
The maximum number of items to be included in the "items" list. If there are any prepended or appended items, this will automatically lower the "limit" to only fetch as many entities as needed. Note that this may also impact both the "page" and "total_pages" values in the resulting entities. In order to use pagination with a list loaded using "max_size" use "start" instead of "page" and "limit".
filter
 
Only include entities that match the given string filter
global_type_id
 
May include multiple types. Only include entities of the given types.
tag
 
May include multiple tags. Only include entities with one of the given tags
author
 
May include multiple authors. Only include entities with one of the given authors
folder
 
May include multiple folders. Only include entities with one of the given folders
date_created_start
 
Only include entities with date_created greater than or equal to date_created_start. Remember that date_created will typically be the date that the entity was first published.
date_created_end
 
Only include entities with date_created less than or equal to date_created_end. Remember that date_created will typically be the date that the entity was first published.
start
 
Set the 1-based index of the first to fetch.
page
 
Used to automatically calculate the first to fetch based on both the "limit" and the 1-based "page" value. Defaults to 1, but is ignored if "start" is set.
limit
 
The maximum number of entities to fetch. Defaults to 10. Note that if "max_size" is defined, then "limit" may be automatically lowered even if specified separately.
sort_by
 
Specify which property to sort the results by. Has no affect on prepended or appended entities. By default, results will be sorted by relevance if there is a filter string and date_created desc (newest first) if not. Options include:
  • relevance: only applies when there is a filter string. When sorting by relevance sort_direction is ignored.
  • date_created: the date each entities was first published. Unpublishing and republishing a entities resets date_created to the current date.
  • random: results will be returned in a random order, which prevents the page from being fast-cached. Setting cache_random:true overrides this behavior and allows the page to be fast-cached anyway.
  • name
  • title
  • url
  • browser_title
sort_direction
 
asc or desc.
cache_random
 
True to allow the results to be cached when sort_by is "random".
Fetches a list of entities.

Examples

To map a collection of entities into a human-readable list of titles linking to the entities:

Copy
{% for entity in collection.items -%}
{{ entity.linked_title }}{% unless forloop.first -%}{% if forloop.length == 2 %} and {% else %}, {% if forloop.last %}and {% endif %}{% endif %}{% endunless %}
{%- endfor %}

Search only blog post entities by a query parameter

Copy
{% search output_to_template request.query_params.q type:blog_post %}

Encode a string for output inside other HTML markup.

Encode HTML entities in a string

Copy
<p title="{{"<p>A string with HTML & other characters</p>" | html_encode}}">...

Decode any encoded HTML entities inside a string.

Decode HTML entities in a string

Copy
{{"&lt;p&gt;A string with HTML &amp; other characters&lt;/p&gt;" | html_decode}}