0

我正在使用basetemplate9Sebastian Klein ( https://github.com/sebkln/basetemplate9 ) 提供的扩展。我使用其他 HTML 模板(来自 Bootstrap)自定义它,当然还调整了后端布局。一切正常,来自后端布局的内容被映射到 HTML 模板。但是,我对当前上传图片的解决方案不满意。

目前,对于 images ,我只是将它们上传到/fileadmin/user_uploads目录中,然后使用 <f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: 'x'}"/>其中 x 是后端布局中定义的一致 colPos 的数量来映射它们。然后使用 TYPO3 样式渲染图像。但我想控制图像属性。无论编辑器编辑什么,图像都应始终以相同的方式呈现。

因此,在 HTML 模板中,我想定义宽度、高度等图像属性,并且我想使用 f:image 视图助手(https://docs.typo3.org/other/typo3/view-helper-reference/9.5/ en-us/typo3/fluid/latest/Image.html)。

我现在的问题是:如何将上传的图像(在后端布局中使用特定的 colPos)映射到图像视图助手的 src 中? <f:image src="{THIS_VALUE_SHOULD_POINT_TO_THE_IMAGE_UPLOADED_VIA_COLPOS_OF_ASSOCIATED_BACKENDLAYOUT}}" width="400" height="200" alt="My Image" />

如果我指定uid对表 sys_file 进行硬编码(在我的情况下是 2),那么我可以使用 FileProcessor“找到”相应的图像(请参见下面的代码),但是如何将此 FileProcessor 嵌套在 DatabaseQueryProcessor 中以便我找到关联的colPos 来自我的后端布局。我错过了这个逻辑。

   // In the FLUIDTEMPLATE TypoScript
   dataProcessing.10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
   dataProcessing.10 {
      references.fieldName = image
      references.table = tt_content
      files = 2 //hardcoded uid of table sys_file

      folders = 1:fileadmin/user_upload/
      folders.recursive = 1
      sorting = description
      sorting.direction = descending

      as = myfiles
   }
<f:for each="{myfiles}" as="file">
  <li><a href="{file.identifier}">{file.name}</a></li>
  <f:image class="img-fluid rounded mb-4 mb-lg-0" 
   src="/fileadmin/{file.identifier}" width="900c" height="400c" 
   alt="Christian Alt Default Titel" title="Christian Default Titel" 
   />
</f:for>

2019 年 7 月 22 日更新

我受到https://www.rutschmann.biz/en/blog/post/dataprocessor-gridelements-und-fal-bilder-im-fluidtemplate-4-beginners/中描述的方法的启发。

基本上,作者使用 tt_content 选择特定 colPos 上传的图像并将记录传递给 FilesProcessor。

我想遵循以下相同的方法,但它基于 Typo3 7 LTS,我使用的是 9.5.8 版本,并且打字稿代码在我的版本中不起作用,尤其是以下代码片段:

 where.wrap = tx_gridelements_columns = 101 AND tx_gridelements_container=|

这是上面链接作者的方法:

imagetextbox < lib.gridelements.defaultGridSetup
    imagetextbox {
        cObject = FLUIDTEMPLATE
        cObject {
            file = EXT:customtheme/Resources/Private/Templates/GridElements/Imagetextbox.html
            dataProcessing {
                10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
                10 {
                    table = tt_content
                    where.data = field:uid
                    where.wrap = tx_gridelements_columns = 101 AND tx_gridelements_container=|
                    orderBy = sorting
                    as = content

                    dataProcessing {
                        10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
                        10 {
                            references.fieldName = image
                            references.table = tt_content
                            as = image
                        }
                    }
                }
            }
        }
        outerWrap = |
    }
4

1 回答 1

0

您应该在每个处理级别验证您的可用数据。你应该知道加工和应用技术。

<f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: 'x'}"/>您一起控制从流体到排版。根据流体的种类,您可能拥有有关当前呈现的列的信息。
如果您想知道所有可用数据,请<f:debug title="pre TS call">{_all}</f:debug>在模板中插入 a。

colPos属于tt_content分配给页面的内容元素(中的记录),该页面具有布局(后端和前端)。仅当存在与-record的连接/关系时,
才可以为其他类型的记录(例如sys_file)分配a 。对于类型为开放的 CE(内容元素),对于新闻()之类的记录,它是类型为“插件”、子类型为“新闻列表”的 CE。colPostt_contenttext with mediatx_news_domain_model_news

当然,对于页面的特定部分,tt_content如果您在打字稿中指定它,您可以在没有 -records 的情况下呈现任何内容。但是关键字colPos没有意义。

目前我无法了解您以何种顺序或上下文使用流体和打字稿的哪些部分,如何为页面识别这些文件(将pages-record 与sys_file-records 连接起来的关系是什么?)

pages -> tt_content -> sys_file
pages -> files in specifc folder
pages -> sys_file
pages -> tt_content -> another kind of record -> sys_file

如果要配置/编程这些依赖项,则必须精确指定依赖项。
第一步:在将其提炼成编程语言之前用文字描述它

于 2019-07-22T05:46:36.930 回答