Skip to content

Latest commit

 

History

History
128 lines (96 loc) · 5.21 KB

content_relations_forward_fields.rst

File metadata and controls

128 lines (96 loc) · 5.21 KB

Forward field Content relations Query Type

This Query Type is used to build queries that fetch Content that is related to from relation type fields of the given Content.

Identifier SiteAPI:Content/Relations/ForwardFields
Own conditions
Common Content conditions
Common query parameters

Examples

Content of type blog_post has relation field images which is used to define relations to image type Content. On full view for blog_post fetch 10 related images sorted by name and paginate them by 10 per page using URL query parameter page.

ibexa:
    system:
        frontend_group:
            ng_content_view:
                full:
                    blog_post:
                        template: '@ibexadesign/content/full/blog_post.html.twig'
                        match:
                            Identifier\ContentType: blog_post
                        queries:
                            related_images:
                                query_type: SiteAPI:Content/Relations/ForwardFields
                                max_per_page: 10
                                page: 1
                                parameters:
                                    relation_field: images
                                    content_type: image
                                    sort: name
<h3>Related images</h3>

<ul>
{% for image in ng_query( 'related_images' ) %}
    <li>
        {{ ng_image_alias( image.fields.image, 'gallery' ) }}
    </li>
{% endfor %}
</ul>

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

Own conditions

content

Defines the source (from) relation Content, which is the one containing relation type 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'

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]