我正在使用Ben Kott的Typo3 9.5站点包,并将内容包含在我的流体模板中,如下所示:
<f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: '1'}" />
我正在尝试将其包裹在像液体这样的情况下
<f:if condition="<f:cObject typoscriptObjectPath='lib.dynamicContent' data='{colPos: \'1\'}'">
whatever
</f:if>
它不起作用。我不知道语法是否有错误或不可能。
答案 0 :(得分:2)
{f:cObject(typoscriptObjectPath: 'lib.dynamicContent', data: {colPos: 1}) -> f:variable(name: 'content')}
<f:if condition="{content}">
There is content. Here it is:
{content -> f:format.raw()}
</f:if>
为后代进行编辑:上面的代码失败的确切原因似乎是语法错误:
<f:if condition="<f:cObject typoscriptObjectPath='lib.dynamicContent' data='{colPos: \'1\'}'">
应该是:
<f:if condition="<f:cObject typoscriptObjectPath='lib.dynamicContent' data='{colPos: \'1\'}' />">
由于内部标签未关闭。您仍然应该避免使用它-改为使用内联语法。在上面放置的代码中,您可以删除-> f:variable()
部分,然后将该表达式用作标记属性值。
答案 1 :(得分:1)
################################################
#### COUNT CONTENT LIB FOR USAGE IN FLUID ####
################################################
#
# EXAMPLE: amount of content elements in colPos 1 of actual PID
# ---------------
# <f:cObject typoscriptObjectPath="lib.countContent" data="{colPos: 1}" />
# {f:cObject(typoscriptObjectPath: 'lib.countContent', data: '{colPos: 1}')}
#
# EXAMPLE: amount of content elements in more than one colPos of actual PID
# ---------------
# <f:cObject typoscriptObjectPath="lib.countContent" data="{colPos: '1,2'}" />
# {f:cObject(typoscriptObjectPath: 'lib.countContent', data: '{colPos: \'1,2\'}')}
#
#
#
#
# Usage examples:
# --------------
#
# <f:if condition="{f:cObject(typoscriptObjectPath: 'lib.countContent', data: '{colPos: 1}')}">
# <f:cObject typoscriptObjectPath="lib.dynamicContent" data="{pageUid: '{data.uid}', colPos: '1', wrap: '<aside class=\"l-aside\">|</aside>'}" />
# </f:if>
#
#
# <f:if condition="{f:cObject(typoscriptObjectPath: 'lib.countContent', data: '{colPos: 1}')}">
# <aside class="l-aside">
# <f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: '1'}" />
# </aside>
# </f:if>
#
#
###############
lib.countContent = COA
lib.countContent {
5 = LOAD_REGISTER
5 {
colPos.cObject = TEXT
colPos.cObject {
field = colPos
ifEmpty.cObject = TEXT
ifEmpty.cObject {
value.current = 1
ifEmpty = 0
}
}
pageUid.cObject = TEXT
pageUid.cObject {
field = pageUid
ifEmpty.data = TSFE:id
}
contentFromPid.cObject = TEXT
contentFromPid.cObject {
data = DB:pages:{register:pageUid}:content_from_pid
data.insertData = 1
}
}
20 = CONTENT
20 {
table = tt_content
select {
selectFields = count(uid) AS counter
where = {#colPos} IN({register:colPos})
where.insertData = 1
pidInList.data = register:pageUid
pidInList.override.data = register:contentFromPid
andWhere = (deleted = 0 AND hidden = 0)
}
renderObj = COA
renderObj {
10 = TEXT
10 {
data = field:counter
}
}
}
90 = RESTORE_REGISTER
}
此代码段已在没有工作空间的TYPO3 8.7 LTS中进行了测试和使用