Typo3 输入3个网格元素。从子级渲染资产

Typo3 输入3个网格元素。从子级渲染资产,typo3,typo3-7.6.x,fal,tx-gridelements,Typo3,Typo3 7.6.x,Fal,Tx Gridelements,我正在使用gridelments创建一个内容元素,在这里我需要直接呈现来自child的一些数据。“bodytext”或“header”等字段没有问题。但是资产只给我一个计数器,而不是一个引用或路径。 所以最大的问题是:我如何渲染孩子们的资产图像 我可以分享我刚才做的VH <?php namespace GeorgRinger\Theme\ViewHelpers; use TYPO3\CMS\Core\Database\DatabaseConnection; use TYPO3\CMS\C

我正在使用gridelments创建一个内容元素,在这里我需要直接呈现来自child的一些数据。“bodytext”或“header”等字段没有问题。但是资产只给我一个计数器,而不是一个引用或路径。
所以最大的问题是:我如何渲染孩子们的资产图像


我可以分享我刚才做的VH

<?php
namespace GeorgRinger\Theme\ViewHelpers;

use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3\CMS\Frontend\Resource\FileCollector;

class FalViewHelper extends AbstractViewHelper
{

    /**
     * @var boolean
     */
    protected $escapeOutput = FALSE;

    /**
     * @param string $table
     * @param string $field
     * @param string $id
     * @param string $as
     * @return string
     */
    public function render($table, $field, $id, $as = 'references')
    {
        $row = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('*', $table, 'uid=' . (int)$id);
        if (!$row) {
            return '';
        }

        $fileCollector = GeneralUtility::makeInstance(FileCollector::class);
        $fileCollector->addFilesFromRelation($table, $field, $row);

        $this->templateVariableContainer->add($as, $fileCollector->getFiles());
        $output = $this->renderChildren();
        $this->templateVariableContainer->remove($as);

        return $output;
    }

    /**
     * @return DatabaseConnection
     */
    protected function getDatabaseConnection()
    {
        return $GLOBALS['TYPO3_DB'];
    }
}

我可以分享我刚才做的VH

<?php
namespace GeorgRinger\Theme\ViewHelpers;

use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3\CMS\Frontend\Resource\FileCollector;

class FalViewHelper extends AbstractViewHelper
{

    /**
     * @var boolean
     */
    protected $escapeOutput = FALSE;

    /**
     * @param string $table
     * @param string $field
     * @param string $id
     * @param string $as
     * @return string
     */
    public function render($table, $field, $id, $as = 'references')
    {
        $row = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('*', $table, 'uid=' . (int)$id);
        if (!$row) {
            return '';
        }

        $fileCollector = GeneralUtility::makeInstance(FileCollector::class);
        $fileCollector->addFilesFromRelation($table, $field, $row);

        $this->templateVariableContainer->add($as, $fileCollector->getFiles());
        $output = $this->renderChildren();
        $this->templateVariableContainer->remove($as);

        return $output;
    }

    /**
     * @return DatabaseConnection
     */
    protected function getDatabaseConnection()
    {
        return $GLOBALS['TYPO3_DB'];
    }
}