TYPO3 8 中显示当前页面的类别名称
Show category names of current page in TYPO3 8
我正在尝试在 TYPO3 8 安装中显示当前页面的类别名称。在 TYPO3 7 中,它曾经像这样工作(见下文),但现在我只收到一个随机错误代码,没有文本输出。有什么想法吗?
lib.catclass = CONTENT
lib.catclass {
wrap = <div class="categories">|</div>
table = sys_category
select {
pidInList = 35 // UiD of your category_page
join = sys_category_record_mm ON(sys_category_record_mm.uid_local=sys_category.uid)
where = sys_category_record_mm.tablenames='pages'
andWhere.dataWrap = sys_category_record_mm.uid_foreign = {TSFE:id}
}
renderObj = TEXT
renderObj.field = title
renderObj.wrap = <li class="category {field:title}">|</li>
renderObj.insertData = 1
}
对应的错误输出如下:
An exception occurred while executing 'SELECT * FROM `sys_category` INNER JOIN `sys_category_record_mm`
`ON(sys_category_record_mm`.`uid_local=sys_category`.`uid)` ON WHERE
(`sys_category`.`pid` IN (35)) AND
(sys_category_record_mm.tablenames='pages') AND (`sys_category`.`sys_language_uid` IN (0, -1)) AND
((`sys_category`.`deleted` = 0) AND (`sys_category`.`t3ver_state` <= 0) AND (`sys_category`.`pid` <> -1) AND (`sys_category`.`hidden` = 0) AND (`sys_category`.`starttime` <= 1546204860) AND
((`sys_category`.`endtime` = 0) OR (`sys_category`.`endtime` > 1546204860)))': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near '.`uid_local=sys_category`.`uid)` ON WHERE (`sys_category`.`pid` IN (35)) AND (s' at line 1
尝试在 ON
之后添加一个 space,因此:
join = sys_category_record_mm ON (sys_category_record_mm.uid_local=sys_category.uid)
此外,andWhere
自 TYPO3 7.1 以来已被弃用,并已在 8 中删除。您需要将其添加到 where
并使用 markers
添加页面 uid。从我的头顶来看,那就是:
lib.catclass = CONTENT
lib.catclass {
wrap = <div class="categories">|</div>
table = sys_category
select {
pidInList = 35 // UiD of your category_page
join = sys_category_record_mm ON (sys_category_record_mm.uid_local=sys_category.uid)
where = sys_category_record_mm.tablenames='pages' AND sys_category_record_mm.uid_foreign = ###pageuid###
markers {
pageuid.data = TSFE:id
}
}
renderObj = TEXT
renderObj.field = title
renderObj.wrap = <li class="category {field:title}">|</li>
renderObj.insertData = 1
}
有关 markers
的更多信息,请参阅 https://docs.typo3.org/typo3cms/TyposcriptReference/8.7/Functions/Select/#markers
我正在尝试在 TYPO3 8 安装中显示当前页面的类别名称。在 TYPO3 7 中,它曾经像这样工作(见下文),但现在我只收到一个随机错误代码,没有文本输出。有什么想法吗?
lib.catclass = CONTENT
lib.catclass {
wrap = <div class="categories">|</div>
table = sys_category
select {
pidInList = 35 // UiD of your category_page
join = sys_category_record_mm ON(sys_category_record_mm.uid_local=sys_category.uid)
where = sys_category_record_mm.tablenames='pages'
andWhere.dataWrap = sys_category_record_mm.uid_foreign = {TSFE:id}
}
renderObj = TEXT
renderObj.field = title
renderObj.wrap = <li class="category {field:title}">|</li>
renderObj.insertData = 1
}
对应的错误输出如下:
An exception occurred while executing 'SELECT * FROM `sys_category` INNER JOIN `sys_category_record_mm`
`ON(sys_category_record_mm`.`uid_local=sys_category`.`uid)` ON WHERE
(`sys_category`.`pid` IN (35)) AND
(sys_category_record_mm.tablenames='pages') AND (`sys_category`.`sys_language_uid` IN (0, -1)) AND
((`sys_category`.`deleted` = 0) AND (`sys_category`.`t3ver_state` <= 0) AND (`sys_category`.`pid` <> -1) AND (`sys_category`.`hidden` = 0) AND (`sys_category`.`starttime` <= 1546204860) AND
((`sys_category`.`endtime` = 0) OR (`sys_category`.`endtime` > 1546204860)))': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near '.`uid_local=sys_category`.`uid)` ON WHERE (`sys_category`.`pid` IN (35)) AND (s' at line 1
尝试在 ON
之后添加一个 space,因此:
join = sys_category_record_mm ON (sys_category_record_mm.uid_local=sys_category.uid)
此外,andWhere
自 TYPO3 7.1 以来已被弃用,并已在 8 中删除。您需要将其添加到 where
并使用 markers
添加页面 uid。从我的头顶来看,那就是:
lib.catclass = CONTENT
lib.catclass {
wrap = <div class="categories">|</div>
table = sys_category
select {
pidInList = 35 // UiD of your category_page
join = sys_category_record_mm ON (sys_category_record_mm.uid_local=sys_category.uid)
where = sys_category_record_mm.tablenames='pages' AND sys_category_record_mm.uid_foreign = ###pageuid###
markers {
pageuid.data = TSFE:id
}
}
renderObj = TEXT
renderObj.field = title
renderObj.wrap = <li class="category {field:title}">|</li>
renderObj.insertData = 1
}
有关 markers