Skip to content

Latest commit

 

History

History
181 lines (132 loc) · 7.14 KB

location_relations_all_tag_fields.rst

File metadata and controls

181 lines (132 loc) · 7.14 KB

All tag fields Location relations Query Type

This Query Type is used to build queries that fetch Locations with Content tag field relations from all tag fields of a given Content.

Hint

Tag field Content relations are Content items tagged with a tag contained in the tag fields of a given Content.

Note

Only visible main Locations of the related Content will be used.

Hint

This query type assumes Netgen's TagsBundle is used for tagging functionality.

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

Examples

On full view for product type Content fetch all Locations with Content of type article that is tagged with any of the tags from the given product. Sort them by name and paginate them by 10 per page using URL query parameter page:

ezpublish:
    system:
        frontend_group:
            ngcontent_view:
                full:
                    product:
                        template: '@ezdesign/content/full/product.html.twig'
                        match:
                            Identifier\ContentType: product
                        queries:
                            related_articles:
                                query_type: SiteAPI:Location/Relations/AllTagFields
                                max_per_page: 10
                                page: '@=queryParam("page", 1)'
                                parameters:
                                    content_type: article
                                    sort: name
{% set articles = ng_query( 'related_articles' ) %}

<h3>Related articles</h3>

<ul>
{% for article in articles %}
    <li>{{ article.content.name }}</li>
{% endfor %}
</ul>

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

Own conditions

content

Defines the source (from) relation Content, which is the one containing tag fields.

Note

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

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

Examples:

# this is also automatically set when using from view builder configuration
content: '@=content'
# fetch relations from Content's main Location parent Location's Content
content: '@=content.mainLocation.parent.content'
# fetch relations from Content's main Location parent Location's parent Location's Content
content: '@=content.mainLocation.parent.parent.content'

exclude_self

Defines whether to include Content defined by the content condition in the result set. If null is used as a value, the condition won't be added.

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

Examples:

# do not include the source relation Content, this is also the default behaviour
exclude_self: true
# include the source relation Content
exclude_self: false

Inherited Location conditions

Defines whether returned Locations are main Locations or not. Use true to get main Locations (which is also the default behaviour), false to get non-main Locations and null to get both.

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

Defines whether returned Locations are main Locations or not. Use true to get main Locations (which is also the default behaviour), false to get non-main Locations and null to get both.

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