TYPO3 Gridelements. Рендеринг активов из дочернего

Я создаю элемент содержимого с gridelments, где мне нужно напрямую отображать некоторые данные из дочерних элементов. Нет проблем с полями, такими как «основной текст» или «заголовок». Но активы дают мне только счетчик, а не ссылку или путь.
Итак, большой вопрос: как я могу визуализировать изображения активов из дочерних элементов?

введите описание изображения здесь


person kevinq    schedule 27.09.2016    source источник


Ответы (1)


Я могу поделиться 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'];
    }
}

Конечно, вам нужно принять namspace.

Использование будет

<theme:fal table="tt_content" field="assets" id=" => the id <= ">
  <f:debug>{references}</f:debug>
</theme:fal>
person Georg Ringer    schedule 27.09.2016