Typo3 如何在打字稿中获取页面类别(并与tx_新闻一起使用)
我想读出一个页面的系统类别,以便与tx_news一起使用(显示与页面类别相同的新闻,因为tx_news使用的是系统类别) 我正在寻找一个本机解决方案,希望通过getText,比如:Typo3 如何在打字稿中获取页面类别(并与tx_新闻一起使用),typo3,typoscript,tx-news,Typo3,Typoscript,Tx News,我想读出一个页面的系统类别,以便与tx_news一起使用(显示与页面类别相同的新闻,因为tx_news使用的是系统类别) 我正在寻找一个本机解决方案,希望通过getText,比如: plugin.tx\u news.settings.categories.data=page:categories 但这似乎还不存在 此外,我还尝试使用sys_category_records_mm简化查询,其中包含该案例所需的所有信息,但TYPO3抱怨“在$TCA数组中没有条目”: 这很好,但这是不允许的。我找到了
plugin.tx\u news.settings.categories.data=page:categories
但这似乎还不存在
此外,我还尝试使用sys_category_records_mm简化查询,其中包含该案例所需的所有信息,但TYPO3抱怨“在$TCA数组中没有条目”:
这很好,但这是不允许的。我找到了这个(德语)并修改它以显示UID类别
以下打字脚本将显示当前页面所有类别的UID,以逗号分隔
10 = CONTENT
10 {
table = pages
select {
uidInList.field = uid
pidInList = 1 # UID or list of UIDs, where your categories are saved
selectFields = sys_category.uid as catUid
join = sys_category_record_mm ON pages.uid = sys_category_record_mm.uid_foreign JOIN sys_category ON sys_category.uid = sys_category_record_mm.uid_local
where = sys_category_record_mm.tablenames = 'pages' AND sys_category_record_mm.uid_foreign = {field:uid}
where.insertData = 1
orderBy = sys_category.sorting
}
renderObj = TEXT
renderObj {
field = catUid
wrap = |,
}
# HACK
# If category is empty, the mechanism below won't work
# As long as I don't know how to query if this is empty or not,
# just add an imaginary extra category!
wrap = 12345,|
}
不幸的是,您必须手动将
pidInList
设置为UID列表,其中存储类别 这里有一个在我的设置中有效的解决方案。编辑器为页面选择类别,并获取属于该类别的所有新闻项
temp.categoryUid = CONTENT
temp.categoryUid {
table = pages
select {
// dontCheckPid doesn't exist for CONTENT objects, so make it recursive from root page (or pidInList.data = leveluid:-2
pidInList = {$pidRoot}
recursive = 99
selectFields = sys_category.uid as catUid
join = sys_category_record_mm ON pages.uid = sys_category_record_mm.uid_foreign JOIN sys_category ON sys_category.uid = sys_category_record_mm.uid_local
where = sys_category_record_mm.tablenames = 'pages' AND sys_category_record_mm.uid_foreign = {TSFE:id}
where.insertData = 1
// not necessary for this use case
// orderBy = sys_category.sorting
}
renderObj = TEXT
renderObj {
field = catUid
// Hack: if there are no cats selected for a page, all news are displayed
// so I just pass a catUid that's quite unlikely
wrap = 999999,|,
}
}
lib.newstest = USER
lib.newstest {
userFunc = tx_extbase_core_bootstrap->run
extensionName = News
pluginName = Pi1
switchableControllerActions {
News {
1 = list
}
}
settings < plugin.tx_news.settings
settings {
limit = 5
orderBy = datetime
orderDirection = desc
detailPid = {$pidNachrichtenDetail}
overrideFlexformSettingsIfEmpty := addToList(detailPid)
startingpoint = {$pidNachrichtenRecords}
// for use in my fluid template
// pluginTitle = {$llAktuell}
// latest = 0
// recordType = aktuell
// https://forge.typo3.org/issues/52978
useStdWrap = categories
categories.override.cObject < temp.categoryUid
categoryConjunction = or
}
view =< plugin.tx_news.view
}
temp.categoryUid=CONTENT
临时分类{
表=页
挑选{
//内容对象的dontCheckPid不存在,因此请从根页面(或pidInList.data=leveluid:-2)将其递归
pidInList={$pidRoot}
递归=99
选择fields=sys\u category.uid作为catUid
join=sys\u category\u record\u mm ON page.uid=sys\u category\u record\u mm.uid\u exforeign join sys\u category.uid=sys\u category\u record\u mm.uid\u local
其中=sys\u category\u record\u mm.tablenames='pages'和sys\u category\u record\u mm.uid\u foreign={TSFE:id}
其中,insertData=1
//此用例不需要
//orderBy=sys\u category.sorting
}
renderObj=文本
伦德罗布{
字段=catUid
//黑客:如果没有为页面选择猫,则显示所有新闻
//所以我只是传递了一个不太可能的catUid
包裹=999999,|,
}
}
lib.newstest=用户
lib.newstest{
userFunc=tx\u extbase\u core\u引导->运行
扩展名=新闻
pluginName=Pi1
可切换控制器动作{
新闻{
1=列表
}
}
设置
我仍然不清楚的是,select中的
recursive=1
是否没有退步。实际上,我根本不想检查当前页面的父uid,但是({current pid})中的WHERE pages.pid总是自动插入。因此recursive=1
查找页面的cat id:
我是这样做的:
lib.cat = CONTENT
lib.cat {
wrap = |
table = sys_category
select {
pidInList = 1
selectFields = sys_category.uid, sys_category.title
max = 1
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 = COA
renderObj {
10 = TEXT
10 {
field = uid
wrap = class="category|
}
20 = TEXT
20 {
field = title
case = lower
stdWrap.noTrimWrap = | |"|
}
}
}
我也看到了这一点,对于本机功能来说,这不是有点复杂吗?起初,我认为类别应该通过getText或类似的方式提供。但那时可能还不存在这种情况?在“显示与页面具有相同类别的新闻”的意义上,您如何将其传递给TXU新闻(由于tx_news使用系统类别,这将非常方便)我也找不到一个本机功能来通过打字脚本获取所有页面类别,因此实际上,使用CONTENT对象似乎是获取类别的唯一有效解决方案。无论如何,我发现,除了一个简单的字符串之外,你不能向“类别”传递任何内容tx_news的打字稿设置。我创建了一个简单的tmp.cat=TEXT tmp.cat.value=1,2
对象,并将其传递给“categories”设置tx_news并引发致命错误,因为对象是一个数组。因此,可能根本不可能通过TS获取类别并将结果传递给tx_news设置。感谢-对于我的使用,我仍然可以将一个类别设置为最大类别。您对该用例的总体看法如何(使用页面类别显示新闻)-这对你有意义吗?我想我会在forge上打开两个功能请求,然后,也许我会尝试RECORDS.categories,这将返回字符串我也尝试了使用记录的方法,但记录似乎不支持select方法,因此你可能会得到所有记录(类别).总的来说,我认为您尝试归档的内容是有意义的,并且我认为检索所有选定的页面类别是缺少的核心功能。如果您允许用户为一个页面设置多个类别,会发生什么情况?
lib.cat = CONTENT
lib.cat {
wrap = |
table = sys_category
select {
pidInList = 1
selectFields = sys_category.uid, sys_category.title
max = 1
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 = COA
renderObj {
10 = TEXT
10 {
field = uid
wrap = class="category|
}
20 = TEXT
20 {
field = title
case = lower
stdWrap.noTrimWrap = | |"|
}
}
}