Skip to content

Latest commit

 

History

History
209 lines (151 loc) · 8.18 KB

location_relations_tag_fields.rst

File metadata and controls

209 lines (151 loc) · 8.18 KB

Tag field Location relations Query Type

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

Hint

Tag field Location relations are Locations whose Content is tagged with a tag contained in a tag field 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/TagFields
Own conditions
Inherited Location conditions
Common Content conditions
Common query parameters

Examples

Your project is a web shop, where Content of type product is tagged with tags that define product's market. Specific tag field named market is used for that. For example, you could have a wireless keyboard product tagged with market tag components. Various other Content is also tagged with that tag, for example we could have files and articles using that same tag.

On the full view for Content of type product, fetch articles from the same market, sort them by their publication date and paginate them by 10 per page using URL query parameter page:

ibexa:
    system:
        frontend_group:
            ng_content_view:
                full:
                    product:
                        template: '@ibexadesign/content/full/product.html.twig'
                        match:
                            Identifier\ContentType: product
                        queries:
                            market_articles:
                                query_type: SiteAPI:Location/Relations/TagFields
                                max_per_page: 10
                                page: '@=queryParam("page", 1)'
                                parameters:
                                    relation_field: market
                                    content_type: article
                                    sort: published desc
{% set articles = ng_query( 'market_articles' ) %}

<h3>Related market 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
location: '@=content'
# fetch relations from Content's main Location parent Location's Content
location: '@=content.mainLocation.parent.content'
# fetch relations from Content's main Location parent Location's parent Location's Content
location: '@=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

relation_field

Defines Content fields to take into account for determining relations.

  • value type: string
  • value format: single, array
  • operators: none
  • target: none
  • required: true
  • default: not defined

Examples:

relation_field: appellation
relation_field: [head, heart, base]

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