pawsitiwe/sulu-collection-content-type

Adds a content type for collections to Sulu CMS

v0.1.2 2023-12-04 00:20 UTC

This package is auto-updated.

Last update: 2024-04-04 01:09:31 UTC


README

Installation

composer require pawsitiwe/sulu-collection-content-type

Setup

Service Registration

The twig extension need to be registered as symfony service.

services:
    Pawsitiwe\SuluCollectionContentType\Twig\CollectionImagesExtension: ~

If autoconfigure is not active you need to tag it with twig.extension.

Usage

Use content type

To use the collection content type, use the following code.

<property name="collection" type="single_collection_selection">
    <meta>
        <title lang="en">Collection</title>
        <title lang="de">Ordner</title>
    </meta>
</property>

Get images of collection

To get all images of a collection, use the following code.

{% set images = get_images_in_collection(content.collection.id) %}

{% for image in images %}
    <img src="{{ image.thumbnails['sulu-400x400'] }}" alt="{{ image.title }}" title="{{ image.description|default(image.title) }}">
{% endfor %}