Typo3 仅限在自定义字段中具有特定值的页面
我在表页面中有一个自定义字段(比如它的名称为myfield),其值为0、1或2。现在,我想为该字段中具有特定值的所有页面(例如myfield=1的所有页面)创建一个Humenu 我怎么能得到这个 据我所知,我不能在纸上加上where条款。那么我需要一个USER_INT吗 它会像这样工作吗:Typo3 仅限在自定义字段中具有特定值的页面,typo3,typoscript,Typo3,Typoscript,我在表页面中有一个自定义字段(比如它的名称为myfield),其值为0、1或2。现在,我想为该字段中具有特定值的所有页面(例如myfield=1的所有页面)创建一个Humenu 我怎么能得到这个 据我所知,我不能在纸上加上where条款。那么我需要一个USER_INT吗 它会像这样工作吗: includeLibs.something = mypath/user_myclass.php lib.servicenav = HMENU lib.servicenav { special = list
includeLibs.something = mypath/user_myclass.php
lib.servicenav = HMENU
lib.servicenav {
special = list
special.value = USER
special.value.userFunc = user_myclass->myFunction
special.value.myfieldvalue = 1 # 0, 1, or 3
}
用户_myclass.php->myFunction:
function myFunction($a, $myfieldvalue) {
// - search all pages with $myfieldvalue
// - add all pids of this page to the returnvalue (as string)
$returnvalue = "5, 19, 200";
return $returnvalue;
}
这个解决方案有效吗?有更好的解决方案吗
编辑:cascavals解决方案:
它在一个小的测试项目中使用:
lib.menu = HMENU
lib.menu{
special = list
special.value.cObject = CONTENT
special.value.cObject {
table = pages
select {
where = myfield=0
}
renderObj = TEXT
renderObj {
field = uid
wrap = |,
}
}
entrylevel = 1
1 = TMENU
1.NO = 1
1.NO.linkWrap =
<div class="menu">|</div>
überschreibt
2 < .1
2.NO.linkWrap =
<div class="menu-ebene2">|</div>
lib.menu=humenu
自由菜单{
特殊=列表
special.value.cObject=内容
特殊.value.cObject{
表=页
挑选{
其中=myfield=0
}
renderObj=文本
伦德罗布{
字段=uid
包裹=|,
}
}
entrylevel=1
1=t菜单
1.NO=1
1.1号连环包装=
|
吕贝尔施雷特
2 < .1
2.2号连环包装=
|
但它在更大的项目中不起作用(我没有得到任何输出):
此外,当我从上面复制菜单时,它在该项目中不起作用
lib.navigation=humenu
库导航{
特殊=列表
special.value.cObject=内容
特殊.value.cObject{
表=页
挑选{
其中=myfield=0
}
renderObj=文本
伦德罗布{
字段=uid
包裹=|,
}
}
1=t菜单
1 {
noBlur=1
expAll=0
wrap=
否=1
没有{
wrapItemAndSub=**|
altText=副标题//标题
title=副标题//标题
}
当前号
CUR.ATagParams=class=“活动”
CUR.wrapItemAndSub=*.*.|
法案<.CUR
ACT=1
ACT.ATagParams=class=“活动”
}
2=t菜单
2 < .1
2 {
expAll=0
包裹=
}
}
作为特殊.value
具有stdWrap
,您仍然可以动态选择页面UID并创建逗号分隔的列表,该列表应为:
lib.servicenav = HMENU
lib.servicenav {
special = list
special.value.cObject = CONTENT
special.value.cObject {
table = pages
select {
pidInList = [UID of the root page of your website]
recursive = 99
where = myfield=1
}
renderObj = TEXT
renderObj {
field = uid
wrap = |,
}
}
}
这个想法很好(而且我关于逗号分隔列表的问题很愚蠢,当然它将是一个带有此换行符的逗号列表)。它在一个小的测试项目中有效。但在我想实施itI的大项目中不起作用。我添加了它在哪里有效和在哪里不起作用的两个示例。你明白为什么它在2ed示例中不起作用吗?再次更新了我的帖子。我是否将我的测试项目中的示例应用到实际项目中并不重要。它只输出“主页”链接,没什么。知道我可以检查什么吗?所以它在一个测试项目中工作,但在另一个项目中不工作?1.测试插入手动项目列表时显示的第二个项目中的菜单。2.确保您有与
where
条件匹配的项目。3.清除TYPO3缓存。是的,在我现在的where子句中:where=1=1
(或者根本不添加它)但我只得到1个UID(这是主页的一个子页面,这就是为什么我只看到“主页”链接。我重写了hole lib.naviation也看到了我得到的UID:lib.navigation=CONTENT lib.navigation{table=pages renderObj=TEXT renderObj{field=UID wrap=|,}
lib.servicenav = HMENU
lib.servicenav {
special = list
special.value.cObject = CONTENT
special.value.cObject {
table = pages
select {
pidInList = [UID of the root page of your website]
recursive = 99
where = myfield=1
}
renderObj = TEXT
renderObj {
field = uid
wrap = |,
}
}
}