我正在尝试在详细视图中获取新闻图像。我想在布局的另一部分使用它。我需要它在新闻扩展之外。所以我尝试了:
7 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
7 {
if.isTrue.data = GP:tx_news_pi1|news
references {
table = tx_news_domain_model_news
fieldName = fal_media
uid.data = GP:tx_news_pi1|news
}
sorting = datetime
sorting.direction = descending
as = news_images
}
但不幸的是 news_images 始终为空,但以下返回我一个网址:
lib.newsimage = FILES
lib.newsimage {
if.isTrue.data = GP:tx_news_pi1|news
references {
table = tx_news_domain_model_news
uid.data = GP:tx_news_pi1|news
fieldName = fal_media
}
maxItems = 1
renderObj = IMG_RESOURCE
renderObj.file {
import.data = file:current:publicUrl
}
}
为什么news_images是空的,但是可以找到url?
对于 FilesProcessor,没有
uid
属性。 FilesProcessor 可以处理 files
、collections
和 folders
。
所以,这应该可以完成工作:
7 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
7 {
if.isTrue.data = GP:tx_news_pi1|news
references {
table = tx_news_domain_model_news
fieldName = fal_media
// vvvv
files.data = GP:tx_news_pi1|news
// ^^^^
}
sorting = datetime
sorting.direction = descending
as = news_images
}