首页 > 解决方案 > TYPO3 CONTENT 选择将参数传递给 USER/USER_INT

问题描述

排版:

lib.category = CONTENT
lib.category {
  table=sys_category
  select {
    pidInList = root
    selectFields = sys_category.*
    join = sys_category_record_mm ON sys_category_record_mm.uid_local = sys_category.uid
    where.field = sys_category_record_mm.uid_foreign = data.uid
    languageField = 0
  }
  renderObj = USER_INT
  renderObj {
    userFunc = InstantAitExt\AitContacts\GetPageCategories->testExecute
    alias = TEXT
    alias.value = data.uid
  }
}

所以我必须将 1-x 参数传递给 testExecute。其中一个参数应该保存给定页面的 uid。这个 uid 被传递给 lib.category=CONTENT 通过

<f:cObject typoscriptObjectPath="lib.category" data="{page}" />

data.uid基本上是这样page.data.uid

问题是如果我传递data.uidalias.value参数,则将“data.uid”作为字符串而不是我需要的实际值。

那么如何将实际的 pageId 传递给 alias.value

此外,查询有效,但我无法验证/调试

where.field = sys_category_record_mm.uid_foreign = data.uid

检查查询是否真的得到正确的值(视图中的页面 id)

非常感谢帮助

标签: typo3typoscripttypo3-9.x

解决方案


您无法调试它,因为它是语法错误。

该属性是where,如果您使用where.field,您想从(当前上下文的)字段中设置值。在等号之后是字段的名称。

但是你给个表情sys_category_record_mm.uid_foreign = data.uid。那无法评价。

你想要的是一个带有数据的表达式。这个数据应该被替换。
因此,您可以对替换的数据(或字段)使用换行

where.data = data.uid
where.wrap = sys_category_record_mm.uid_foreign = |

这等于

where.field= uid
where.wrap = sys_category_record_mm.uid_foreign = |

data当前上下文一样,因此您可以直接访问该字段。

或者您使用insertData

where = sys_category_record_mm.uid_foreign = {data.uid}
where.insertData = 1

编辑:

如果您只想将页面 uid 提交给您可以使用的打字稿视图助手
<f:cObject typoscriptObjectPath="lib.category" data="{page.uid}" />或一个简单的数组,例如:
<f:cObject typoscriptObjectPath="lib.category" data="{uid:page.uid}" />

而第二次调用不会更改上面的打字稿(您只有一个较小的data数组,其中仅包含该字段uid,而原始调用包含整个页面记录)。

对于只有 uid 值的 viewhelper,您必须使用current

where = current
where.wrap = sys_category_record_mm.uid_foreign = |

推荐阅读