首页 > 解决方案 > Typoscript DatabaseQueryProcessor - 如果字段为空则滑动

问题描述

我的页面设置中有一个 mm 关系字段。

$myext_pages_fields = array(
    'tx_myext_topofferitem' => Array(
        'label' => 'Relation',
        'config' => Array(
            'type' => 'group',
            'internal_type' => 'db',
            'allowed' => 'tx_myext_topofferitem',
            'MM' => 'tt_content_tx_topofferitem_mm',
            'size' => '20',
            'maxitems' => '99',
            'show_thumbs' => '1',
            'suggestOptions' => [
                'default' => [
                    'searchWholePhrase' => 1
                ],
                'pages' => [
                    'searchCondition' => 'doktype = 1'
                ]
            ],
        )
    ),
);

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('pages', $myext_pages_fields);

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages', '--div--;Top Offers,tx_myext_topofferitem');

如果该字段为空 - 应给出下一个填充的根行页面的项目。

为了获得这些项目,我使用了这样的 DatabaseQueryProcessor。

page = PAGE
page {
  10 = FLUIDTEMPLATE
  10 {
    200 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
    200 {
      table = tx_myext_topofferitem
      pidInList = root,-1
      recursive = 99
      selectFields = tx_myext_topofferitem.*
      join = tt_content_tx_topofferitem_mm ON tt_content_tx_topofferitem_mm.uid_foreign = tx_myext_topofferitem.uid
      where.data = field:uid
      where.intval = 1
      where.wrap = tt_content_tx_topofferitem_mm.uid_local=|
      orderBy = tt_content_tx_topofferitem_mm.sorting
      as = tx_myext_topofferitem_items
    }
  }
}

我尝试将其用作where.data,但这不起作用。

levelfield : -1 , uid, slide

(TYPO3 9LTS)

标签: typo3typo3-9.x

解决方案


看来这里最好使用嵌套数据处理。因此,首先获取一个根行菜单,然后获取属于该菜单特定页面的项目。

page = PAGE
page {
    10 = FLUIDTEMPLATE
    10 {
        dataProcessing {
            10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
            10 {
                special = rootline
                special.range = 0|-1
                special.reverseOrder = 1
                as = rootline
                dataProcessing {
                    10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
                    10 {
                        if.isTrue.field = tx_myext_topofferitem
                        table = tx_myext_topofferitem
                        pidInList.field = uid
                        selectFields = tx_myext_topofferitem.*
                        join = tt_content_tx_topofferitem_mm ON tt_content_tx_topofferitem_mm.uid_foreign = tx_myext_topofferitem.uid
                        where.data = field:uid
                        where.intval = 1
                        where.wrap = tt_content_tx_topofferitem_mm.uid_local=|
                        orderBy = tt_content_tx_topofferitem_mm.sorting
                        as = tx_myext_topofferitem_items
                    }
                }
            }
        }
    }
}

推荐阅读