0

我有一个将值存储在 FlexForm 中的内容元素(例如 1234)。该值表示数据库表的 UID。

我想做什么

  • 获取存储在 FlexForm 中的单个值(已经工作)
  • 使用此值运行数据库查询
  • 在前端显示数据

问题:我不知道如何将 FlexForm 值移交给 DB 查询的 where 子句。

tt_content {
  my_addresscontainer =< lib.contentElement
  my_addresscontainer {

    templateName = AddressContainer
    templateRootPaths {
      10 = EXT:xyz/Resources/Private/Partials/ContentElements/
    }
    partialRootPaths {
      10 = EXT:xyz/Resources/Private/Partials
    }

    dataProcessing {
        1 = xyz\DataProcessing\FlexFormProcessor
        1 {
            options {
                if.isTrue.field = pi_flexform
                fieldName = pi_flexform
            }
            as = content
        }

        10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
               10 {
                  table = tt_address
                  pidInList = 19
                  markers {
                        myuid.value = 191901 <- This should be handed over...
                  }
                  where = uid =###myuid###
                  as = address_record
                }
    }
  }
}

先感谢您。

4

1 回答 1

0

如果您只想从您的插件/内容元素中访问 flexform 值,您可以在没有自定义 FlexFormProcessor 的情况下做到这一点。使用数据类型flexform,例如这样:

dataProcessing {
  10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
  10 {
    table = tt_address
    pidInList = 19
    uidInList.data = flexform:pi_flexform:settings.myuid
  }
}

您需要settings.myuid根据您的flexform中的命名进行调整。有关数据类型flexform的详细信息,请参阅 TypoScript 参考。

如果您需要自定义 FlexFormProcessor,则需要嵌套 dataProcessing,如下所示:

dataProcessing {
  1 = xyz\DataProcessing\FlexFormProcessor
  1 {
    options {
      if.isTrue.field = pi_flexform
      fieldName = pi_flexform
    }
    as = content

    dataProcessing {
      1 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
      1 {
        table = tt_address
        pidInList = 19
        markers {
              myuid.value = 191901 <- This should be handed over...
        }
        where.wrap = uid =|
        as = address_record
      }
    }
  }
}

重要的一行是where.wrap您使用第一个 dataProcessing 中的值的位置。

于 2021-09-06T06:29:05.010 回答