0

I've added several fields to extend the tx_news, some of them should include images. For that I created fields with ...'type' => 'inline','foreign_table' => 'sys_file_reference'..., and it works fine in the backend. Now I want to access the images via Fluid and show them in my news (list and detail), but I cannot manage to get it work. Normal fields I can show with {newsItem.fieldname}, but here I get only the reference. I tried several ways with FilesProcessor, but I cannot get it work, for example:

dataProcessing{
    10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
    10 {
        references {
            table = tx_news_domain_model_news
            fieldName = fieldname
        }
        as = images
    }
}

I am happy for any suggestion! Thanks

EDIT: Here is a part of my tx_news_domain_model_news.php

'tx_csnewsextend_adressefoto' => [
        'label' => 'Landkarte',
        'exclude' => 1,
        'config' => [
            'type' => 'inline',
            'foreign_table' => 'sys_file_reference',
            'foreign_field' => 'uid_foreign',
            'foreign_sortby' => 'sorting_foreign',
            'foreign_table_field' => 'tablenames',
            'foreign_match_fields' => [
                'fieldname' => 'adressefotos',
            ],
            'foreign_label' => 'uid_local',
            'foreign_selector' => 'uid_local',
            'overrideChildTca' => [
                'columns' => [
                    'uid_local' => [
                        'config' => [
                            'appearance' => [
                                'elementBrowserType' => 'file',
                                'elementBrowserAllowed' => 'gif,jpg,jpeg,tif,tiff,bmp,pcx,tga,png,pdf,ai,svg',
                            ],
                        ],
                    ],
                    'crop' => [
                        'description' => 'field description',
                    ],
                ],
                'types' => [
                    2 => [
                        'showitem' => '
                            --palette--;;imageoverlayPalette,
                            --palette--;;filePalette',
                    ],
                ],
            ],
            'maxitems' => 1,
            'filter' => [
                [
                    'userFunc' => 'TYPO3\\CMS\\Core\\Resource\\Filter\\FileExtensionFilter->filterInlineChildren',
                    'parameters' => [
                        'allowedFileExtensions' => 'gif,jpg,jpeg,tif,tiff,bmp,pcx,tga,png,pdf,ai,svg',
                        'disallowedFileExtensions' => '',
                    ],
                ],
            ],
            'appearance' => [
                'useSortable' => true,
                'headerThumbnail' => [
                    'field' => 'uid_local',
                    'height' => '45m',
                ],
                'enabledControls' => [
                    'info' => true,
                    'new' => false,
                    'dragdrop' => true,
                    'sort' => false,
                    'hide' => true,
                    'delete' => true,
                ],
                'createNewRelationLinkTitle' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:images.addFileReference',
            ],
        ],
    ],

EDIT 2: Here is the news.php

class News extends \GeorgRinger\News\Domain\Model\News
{
    /**
     * @var string
     */
    protected $txCsnewsextendAdresse;

    /**
     * @return string
     */
    public function getTxCsnewsextendAdresse()
    {
        return $this->txCsnewsextendAdresse;
    }

    /**
     * @param string $txCsnewsextendAdresse
     */
    public function setTxCsnewsextendAdresse($txCsnewsextendAdresse)
    {
        $this->txCsnewsextendAdresse = $txCsnewsextendAdresse;
    }
    
    /****************************************/
    
    /**
     * @var string
     */
    protected $txCsnewsextendAdressesonstiges;

    /**
     * @return string
     */
    public function getTxCsnewsextendAdressesonstiges()
    {
        return $this->txCsnewsextendAdressesonstiges;
    }

    /**
     * @param string $txCsnewsextendAdressesonstiges
     */
    public function setTxCsnewsextendAdressesonstiges($txCsnewsextendAdressesonstiges)
    {
        $this->txCsnewsextendAdressesonstiges = $txCsnewsextendAdressesonstiges;
    }
    
    /****************************************/
    
    /**
     * @var string
     */
    protected $txCsnewsextendAdressefoto;

    /**
     * @return string
     */
    public function getTxCsnewsextendAdressefoto()
    {
        return $this->txCsnewsextendAdressefoto;
    }

    /**
     * @param string $txCsnewsextendAdressefoto
     */
    public function setTxCsnewsextendAdressefoto($txCsnewsextendAdressefoto)
    {
        $this->txCsnewsextendAdressefoto = $txCsnewsextendAdressefoto;
    }
    
    /****************************************/
    
    /**
     * @var string
     */
    protected $txCsnewsextendGeschichte;
    /**
     * @return string
     */
    public function getTxCsnewsextendGeschichte()
    {
        return $this->txCsnewsextendGeschichte;
    }

    /**
     * @param string $txCsnewsextendGeschichte
     */
    public function setTxCsnewsextendGeschichte($txCsnewsextendGeschichte)
    {
        $this->txCsnewsextendGeschichte = $txCsnewsextendGeschichte;
    }
    
    /****************************************/
}

sunspot
  • 11
  • 4
  • Have you tried the `f:image` ViewHelper from Fluid along with the `treatIdAsReference` option? https://docs.typo3.org/other/typo3/view-helper-reference/main/en-us/typo3/fluid/latest/Image.html – yunzen Mar 29 '23 at 13:00
  • But it is not the ID which is saved in the field, as I understood it is only the reference, like 1 (if I uploaded one picture) or 2 (if I uploaded two pictures) ... – sunspot Mar 29 '23 at 13:49
  • What about ``? – yunzen Mar 29 '23 at 14:13
  • Expanding the table but not the model is somewhat error-prone and makes it complicated to use. Just expand the news model: https://docs.typo3.org/p/georgringer/news/main/en-us/Tutorials/ExtendNews/ProxyClassGenerator/Index.html#register-the-class – Julian Hofmann Mar 29 '23 at 19:17
  • I did it like in the tutorial, I extended the ext_tables.sql, I added the fields to tx_news_domain_model_news.php, and I extended the model at news.php with the new field names. {newsItem.fieldname} returns "1", but this is not the uid of the sys_file_reference, it is only the amount of files saved, like it is in the field "fal_media" – sunspot Mar 30 '23 at 06:13
  • Would you please add (parts of) your tx_news_domain_model_news.php in your post? If declared with the correct datatype, in your news-objects `fieldname` should be an ObjectStorage holding FileReference-objects. So, there won't be a need to resolve this relation manually. – Julian Hofmann Mar 30 '23 at 07:03
  • I've added the code to the main post, thanks!!! – sunspot Mar 30 '23 at 07:26
  • Oh, @sunspot, sorry, I had mixed up the file names.. news.php (the domain model) would be the more interesting one. – Julian Hofmann Mar 30 '23 at 14:07
  • Added the code of the news.php, thanks! – sunspot Mar 31 '23 at 08:57

0 Answers0