TYPO3 扩展;读取域中的自定义 FAL 变量以在流体模板中使用 [英] TYPO3 extension; read custom FAL variable in the domain to use in fluid template

查看:26
本文介绍了TYPO3 扩展;读取域中的自定义 FAL 变量以在流体模板中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的自定义扩展中,我为需要读取的图像元数据引入了一个二进制变量,类似于 在列表视图中显示"tx_news.

In my custom extension I introduced a binary variable to the image metadata that needs to be read, similar to the "Show in list view" of tx_news.

tx_news 为例,我能够添加变量,新调色板在后端显示复选框,并且选择在 sys_file_reference 的新数据库字段中注册 表...

With tx_news as example I was able to add the variable, the new palette shows the checkbox in the backend and the selection is registered in a new database field in the sys_file_reference table ...

现在我需要在我的流体模板中使用这个变量,在这里我失去了踪迹;对象是items,新变量名为opentab,我在域中声明变量如下:

now I need to use this variable in my fluid templates, and here I lose the trail; the objects are items and the new variable is named opentab, I declare the variable as follows in the domain:

/**
 * items
 * 
 * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
 * @lazy
 */
protected $items = null;

/**
 * items with opentab set
 *
 * @var array
 * @transient
 */
protected $itemsOpen;

这是我尝试在选中 opentab 的情况下阅读项目的方式:

this is how I try to read the items with opentab checked:

/**
 * Get open items
 *
 * @return array
 */
public function getItemsOpen()
{
    $itemOpen = [];
    foreach ($this->getItems() as $item) {
        if ($item->getOriginalResource()->getProperty('opentab')) {
            $itemOpen[] = $item;
        }
    }
    return $itemOpen;
}

在我的流体模板中使用 我确实看到了变量 itemsOpen 但没有数据库为该字段包含的任何值...

with <f:debug> in my fluid template I do see the variable itemsOpen but no value whatever the db contains for this field ...

我的商品 TCA:

    'items' => [
        'exclude' => 1,
        'label' => $ll . 'tx_trader_domain_model_object.floorplans',
        'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
            'items',
            [
                'appearance' => [
                    'createNewRelationLinkTitle' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:images.addFileReference'
                ],
                // custom configuration for displaying fields in the overlay/reference table
                // to use the itemsPalette and imageoverlayPalette instead of the basicoverlayPalette
                'foreign_types' => [
                    '0' => [
                        'showitem' => '
                            --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;itemsPalette,
                            --palette--;;imageoverlayPalette,
                            --palette--;;filePalette'
                    ],
                    \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [
                        'showitem' => '
                            --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;itemsPalette,
                            --palette--;;imageoverlayPalette,
                            --palette--;;filePalette'
                    ],
                    \TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [
                        'showitem' => '
                            --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;itemsPalette,
                            --palette--;;imageoverlayPalette,
                            --palette--;;filePalette'
                    ]
               ]
           ],
           'gif,jpg,jpeg,png,pdf'
       ),

    ],

推荐答案

Fluid 神奇地调用了 getter 方法.所以试试 {object.itemsOpen}.

Fluid calls magically the getter methods. So try <f:debug>{object.itemsOpen}</f:debug>.

该属性将保持为空,因为您没有在任何地方填充它.它没有在你的 getter 中使用

The property will stay empty since you do not fill it anywhere. It isn't used in your getter

这篇关于TYPO3 扩展;读取域中的自定义 FAL 变量以在流体模板中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆