![](/img/trans.png)
[英]Typo3 11: How to extend sys_file_reference with another sys_file_reference?
[英]TYPO3 get file object from sys_file_reference
我希望能够在后端添加一个后备视频文件。 因此,对于不支持主要文件格式的浏览器,后端用户可以添加不同文件格式的相同视频。 示例:主要视频文件格式为 ist.webm,次要文件格式为 a.mp4。
我为 sys_file_reference.php 创建了 TCA Overrider
$temporaryColumn = array(
'tx_framework_video_fallback' => [
'label' => 'LLL:EXT:gizmo_framework/Resources/Private/Language/locallang_be.xlf:Pages.videoOptionFallbackVideo.Title',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('tx_framework_video_fallback', [
'appearance' => [
'createNewRelationLinkTitle' => 'LLL:EXT:gizmo_framework/Resources/Private/Language/locallang_be.xlf:Pages.videoOptionPoster.addPoster'
],
],
//Filter for File Types ex. images
'mp4,gif,mov')
],
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'sys_file_reference',
$temporaryColumn
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
'sys_file_reference',
'videoOverlayPalette',
'--linebreak--,tx_framework_video_fallback',
'after:autoplay'
);
这是 ext_table.sql
CREATE TABLE `sys_file_reference` (
'tx_framework_video_fallback' int(11) unsigned DEFAULT '0' NOT NULL,
);
我通过内容元素打字稿加载视频
tt_content.textmedia =< lib.contentElement
tt_content.textmedia {
templateName = Textmedia
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = assets
}
20 = TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor
20 {
maxGalleryWidth = {$styles.content.textmedia.maxW}
maxGalleryWidthInText = {$styles.content.textmedia.maxWInText}
columnSpacing = {$styles.content.textmedia.columnSpacing}
borderWidth = {$styles.content.textmedia.borderWidth}
borderPadding = {$styles.content.textmedia.borderPadding}
}
}
}
到目前为止一切顺利,我可以在后端的内容元素中添加一个视频,它将显示在前端。
但我无法加载链接到 sys_file_reference 的视频。 它被正确保护并添加到 sys_file_reference 表中。
我试图在内容元素打字稿的 dataProcessor 中加载后备视频
tt_content.textmedia =< lib.contentElement
tt_content.textmedia {
templateName = Textmedia
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = assets
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10{
references.table = sys_file_reference
references.fieldName = tx_framework_video_fallback
as = fallbackMediaReference
}
}
}
20 = TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor
20 {
maxGalleryWidth = {$styles.content.textmedia.maxW}
maxGalleryWidthInText = {$styles.content.textmedia.maxWInText}
columnSpacing = {$styles.content.textmedia.columnSpacing}
borderWidth = {$styles.content.textmedia.borderWidth}
borderPadding = {$styles.content.textmedia.borderPadding}
}
}
}
我也尝试过使用 DatabaseQueryProcessor,但我从来没有得到视频的 object 文件。
如何设置 dataProcessing 以加载链接到主文件的 sys_file_reference 的辅助文件。
谢谢你的帮助!
由于文件处理器中目前没有其他可用的数据处理,您要么必须为您自己的自定义数据处理器使用dataProcessing
,要么创建一个解决方法。
解决方法确实可以基于DatabaseQueryProcessor
,因为这将为您提供 FilesProcessor 中仍然缺少的额外数据处理器。 另一方面,您可以使用 go 进行额外的FLUIDTEMPLATE
设置,以便在渲染 FilesProcessor 提供的文件列表时使用。
如果您更喜欢DatabaseQueryProcessor
,则必须使用连接查询来获取必要的文件,这可能会更复杂一些。
https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/Functions/Select.html
如果您使用 go 获得额外的FLUIDTEMPLATE
,您可以在渲染主文件列表时使用f:cObject
视图助手添加它,并将参考记录作为data
移交。
如果您希望在 FilesProcessor 本身内解决该问题,您可能需要支持此问题,该问题已在上一个 TYPO3 倡议周https://forge.ZDC117C9322DEB502C307B16769A8A62E.org
这是我使用 FLUIDTEMPLATE f:cObject 的答案。 感谢乔哈森瑙的提示!
我希望我能帮助有同样问题的人。
流体模板.html:
<f:cObject typoscriptObjectPath="lib.fallbackMedia" data="{file}"/>
setup.typoscript
lib.fallbackMedia = FILES
lib.fallbackMedia {
//references the table, field and which uid it should get
references{
table = sys_file_reference
fieldName = tx_framework_video_fallback
uid.data = uid
}
//renders the references as an IMG Resource
renderObj = COA
renderObj {
10 = IMG_RESOURCE
10 {
file.import.dataWrap = {file:current:storage}:{file:current:identifier}
stdWrap.dataWrap = <source src="|" type="{file:current:mime_type}">
}
}
}
有关 FILES cObject 的更多信息: https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/ContentObjects/Files/Index.ZFC35FDC70D5FC69D23698C
在流体模板中,您现在可以使用多个源构建 HTML 视频标签。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.