SyliusCon 2025
Early Bird Deal
LogoLogo
🛣️ Roadmap💻 Sylius Demo💬 Community Slack
  • Sylius Documentation
  • Sylius Plugins
  • Sylius Stack
  • Sylius CMS Plugin
    • Installation
    • Features Overview
      • Collections
      • Content Templates
      • Pages
      • Blocks
      • Media
    • Developer Reference
      • Collections
      • Pages
      • Blocks
      • Media
      • Content Elements
      • Templates
Powered by GitBook
LogoLogo

Developer

  • Community
  • Online Course

About

  • Team

© 2025 Sylius. All Rights Reserved

On this page
  • Design with Twig Hooks
  • Example:
  • Design directly in Twig Template
  • Miscellaneous

Was this helpful?

  1. Sylius CMS Plugin
  2. Developer Reference

Collections

Design with Twig Hooks

Use the sylius_cms.shop:render:collection component and pass the following props:

  • code (string, required) The unique identifier of the collection you want to render.

  • count_to_render (int, optional) Limits the number of items displayed:

    • If count_to_render ≤ 0, all items in the collection will be rendered.

    • If count_to_render exceeds the total number of items, all items will be rendered.

    • Otherwise, only the specified number of items will be rendered.

  • template (string, optional) Path to a custom Twig template for rendering the collection. When you provide your own template, you are responsible for rendering the collection items inside it. For example, your template might look like this:

    {# templates/collection/custom.html.twig #}
    <div>
      {{ content|raw }}
    </div>
    

Example:

sylius_twig_hooks:
    hooks:
        'sylius_shop.product.show.content.info.overview.accordion.details':
            dynamic_details:
                component: 'sylius_cms.shop:render:collection'
                props:
                    code: 'some_collection_code'
                    count_to_render: 1
                    template: 'collection/custom.html.twig'

Design directly in Twig Template

Just call the predefined Twig function:

{{ sylius_cms_render_collection('some_collection_code') }}

You can also customize how many items are rendered and use your own template:

{{ sylius_cms_render_collection(
    'some_collection_code', 
    3,
    'collection/custom.html.twig'
) }}

Miscellaneous

By default, collection items are sorted by their object ID. To change this behavior, you can use a decorator strategy.

PreviousDeveloper ReferenceNextPages

Last updated 5 days ago

Was this helpful?

Learn more about it .

here