首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何用TYPO3中的流体在正面显示多幅图像?

如何用TYPO3中的流体在正面显示多幅图像?
EN

Stack Overflow用户
提问于 2022-07-04 10:00:53
回答 1查看 195关注 0票数 0

我想用液体在正面显示两张图片。

我试过这些:

添加模型"MultipleImages.php":的

代码语言:javascript
运行
复制
<?php
        /**
         * carouselStartseiteMultipleImages
         *
         * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
         * @lazy
         */
        protected $carouselStartseiteMultipleImages = NULL;

        /**
         * Constructor
         *
         * @return AbstractObject
         */
        public function __construct() {
                // ObjectStorage is needed to reference multiple files to one field
                // see also @var before variable and @return before the respective get() method
                $this->carouselStartseiteMultipleImages = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        }

        /**
         * returns carouselStartseiteMultipleImages
         *
         * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
         */
        public function getcarouselStartseiteMultipleImages() {
                return $this->carouselStartseiteMultipleImages;
        }

        /**
         * sets carouselStartseiteMultipleImages
         *
         * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $carouselStartseiteMultipleImages
         * @return void
         */
        public function setcarouselStartseiteMultipleImages($carouselStartseiteMultipleImages) {
                $this->carouselStartseiteMultipleImages = $carouselStartseiteMultipleImages;
        }
?>

  1. 在TCA:

中添加一个文件

代码语言:javascript
运行
复制
'tx_carousel_startseite_angebote_image' => array(
            'exclude' => 1,
            'label' => 'Image für Klassen- & Gruppenreisen (links)',
            'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
                    'carouselStartseiteMultipleImages',
                    array('minitems'=>0,'maxitems'=>2),
                    $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
                ),
        ),

我想添加两张图片:

用于子项目名称tx_carousel_startseite_angebote_item的表。图像的文件名是tx_carousel_startseite_angebote_image

在我的HTML文件中:

代码语言:javascript
运行
复制
<f:for each="{https://mydomain/.tx_carousel_startseite_angebote_image}" as="pic">
    <f:image src="{pic.originalResource.publicUrl}" alt="{pic.originalResource.alternative}" title="{pic.originalResource.title}" ></f:image>
    {pic.originalResource.description}
</f:for>

但是我的图像没有显示在前面,有一个错误:

代码语言:javascript
运行
复制
Oops, an error occurred! Code: 202207040952376ac3ea67

我还试图在html文件中编写这个流体:

代码语言:javascript
运行
复制
<f:for each="{item.data.tx_carousel_startseite_angebote_image.0}" as="pic1">
    <f:image src="pic1" class="carousel-startseite-angebote-image" height="580" width="600" alt="{pic1.properties.alt}" title="{pic1.properties.title}" />
</f:for>

然后没有错误,但图像没有显示。

我的调试如下:

在“项目>数据”中有以下数据:

但我不能展示我的照片。如何在前面显示多个图像?谢谢你的帮助。

添加:我添加了两个打字本,现在在我的打字本中:

代码语言:javascript
运行
复制
tt_content.carousel_startseite_angebote >
tt_content.carousel_startseite_angebote =< lib.contentElement
tt_content.carousel_startseite_angebote {
    
    templateName = CarouselStartseiteAngebote
    templateRootPaths.150 = EXT:myExtentionkey/Resources/Private/Templates/ContentElements/
    partialRootPaths.150 = EXT:myExtentionkey/Resources/Private/Partials/ContentElements/
    layoutRootPaths.150 = EXT:myExtentionkey/Resources/Private/Layouts/ContentElements/

    dataProcessing {        
        15 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
        15 {
            as = images
            references.fieldName = tx_carousel_startseite_angebote_image
            references.table = tx_carousel_startseite_angebote_item
            sorting = title
            sorting.direction = descending
        }        
        
        20 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
        20 {
            table = tx_carousel_startseite_angebote_item
            pidInList.field = pid
            where {
                data = field:uid
                intval = 1
                wrap = tt_content=|
            }
            orderBy = sorting
            dataProcessing {
                10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
                10 {
                    references.fieldName = background_image
                    as = backgroundImage
                }
                20 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
                20 {
                    references {
                        table = tx_carousel_startseite_angebote_item
                        fieldName = tx_carousel_startseite_angebote_image
                    }
                    as = csaMultipleImages
                }

我的调试现在:

没有数据..。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-07-04 11:58:26

您的图像字段只保存图像的计数,因此无法直接访问和显示它。相反,您应该在打印文本呈现定义中添加一个FileProcessor,以解决与文件的关系。

对于自定义的内容元素,它可以如下所示:

代码语言:javascript
运行
复制
tt_content {
   examples_dataprocfiles =< lib.contentElement
   examples_dataprocfiles {
      templateName = DataProcFiles
      dataProcessing.10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
      dataProcessing.10 {
         as = images
         references.fieldName = image
         references.table = tt_content
         sorting = title
         sorting.direction = descending
      }
   }
}

然后处理流体输出,如下所示:

代码语言:javascript
运行
复制
<f:for each="{images}" as="image">
     <f:image image="{image}" height="250"/>
</f:for>

参见文档和这里的更详细的示例:https://docs.typo3.org/m/typo3/reference-typoscript/11.5/en-us/ContentObjects/Fluidtemplate/DataProcessing/FilesProcessor.html#typoscript

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72854941

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档