2016-09-27 1 views
0

私は子要素から直接いくつかのデータをレンダリングする必要のあるグリッドを持つコンテンツ要素を作成しています。 "bodytext"や "header"のようなフィールドには問題ありません。しかし、資産は私にカウンターだけを提供し、参照や経路は提供しません。
大きな質問:子供の資産イメージをどのようにレンダーすることができますか?TYPO3ギフト。子からのアセットをレンダーする

enter image description here

答えて

2

私はちょうどあなたがnamspaceを採用する必要がある。もちろん、

<?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を共有することができます。

使い方は以下のようになり

<theme:fal table="tt_content" field="assets" id=" => the id <= "> 
    <f:debug>{references}</f:debug> 
</theme:fal> 
関連する問題