赵亚威/sulu-collection-content-type

为 Sulu CMS 添加集合内容类型

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

This package is auto-updated.

Last update: 2024-09-04 02:01:05 UTC


README

安装

composer require pawsitiwe/sulu-collection-content-type

设置

服务注册

需要将 twig 扩展注册为 symfony 服务

services:
    Pawsitiwe\SuluCollectionContentType\Twig\CollectionImagesExtension: ~

如果自动配置未激活,您需要使用 twig.extension 标签。

用法

使用内容类型

要使用集合内容类型,请使用以下代码。

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

获取集合的图像

要获取集合的所有图像,请使用以下代码。

{% 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 %}