Skip to content

Latest commit

 

History

History
194 lines (144 loc) · 6.9 KB

location_subtree.rst

File metadata and controls

194 lines (144 loc) · 6.9 KB

Location subtree Query Type

This Query Type is used to build queries that fetch from the Location subtree.

Identifier SiteAPI:Location/Subtree
Own conditions
Inherited Location conditions
Common Content conditions
Common query parameters

Examples

Subtree of the calendar type Location contains event type Locations. On the full view for calendar fetch all pending events from its subtree up to depth of 3, sort them by their start date and paginate them by 10 per page using URL query parameter page:

ezpublish:
    system:
        frontend_group:
            ngcontent_view:
                full:
                    calendar:
                        template: '@ezdesign/content/full/calendar.html.twig'
                        match:
                            Identifier\ContentType: calendar
                        queries:
                            pending_events:
                                query_type: SiteAPI:Location/Subtree
                                max_per_page: 10
                                page: '@=queryParam("page", 1)'
                                parameters:
                                    content_type: event
                                    relative_depth:
                                        lte: 3
                                    field:
                                        start_date:
                                            gt: '@=timestamp("today")'
                                    sort: field/event/start_date asc
{% set events = ng_query( 'pending_events' ) %}

<h3>Pending events</h3>

<ul>
{% for event in events %}
    <li>{{ event.content.name }}</li>
{% endfor %}
</ul>

{{ pagerfanta( events, 'twitter_bootstrap' ) }}

Own conditions

exclude_self

Defines whether to include Location defined by the location condition in the result set.

  • value type: boolean
  • value format: single
  • operators: none
  • target: none
  • required: false
  • default: true

Examples:

# do not include the subtree root Location, this is also default behaviour
exclude_self: true
# include the subtree root Location
exclude_self: false

location

Defines the root Location of the Location subtree.

Note

This condition is required. It's also automatically set to the Location instance resolved by the view builder if the query is defined in the view builder configuration.

  • value type: Location
  • value format: single
  • operators: none
  • target: none
  • required: true
  • default: not defined

Examples:

# this is also automatically set when using from view builder configuration
location: '@=location'
# fetch from subtree of the parent Location
location: '@=location.parent'
# fetch from subtree of the parent Location's parent Location
location: '@=location.parent.parent'

relative_depth

Defines depth of the Location in the tree relative to the Location defined by location condition.

  • value type: integer
  • value format: single, array
  • operators: eq, in, gt, gte, lt, lte, between
  • target: none
  • required: false
  • default: not defined

Examples:

# identical to the example below
relative_depth: 2
relative_depth:
    eq: 2
# identical to the example below
relative_depth: [2, 3]
relative_depth:
    in: [2, 3]
# multiple operators are combined with logical AND
relative_depth:
    in: [2, 3]
    gt: 1
    lte: 3
relative_depth:
    between: [2, 4]

Inherited Location conditions