【发布时间】:2017-07-30 15:16:18
【问题描述】:
我找到了我想为自己使用的这个很酷的解决方案。 (Example) 这是一个如何使用 FAL 和 DCE 来获取多个图像的示例。
如果我尝试此解决方案,我将在我的网站上收到以下错误输出:
糟糕,发生错误!代码:20170309155903dbbf0d11
有时我什么也得不到,没有错误没有图像。
详细说明我的解决方案: 我使用具有相同配置的文件抽象层,除了最后两行:
<config>
<type>inline</type>
<foreign_table>sys_file_reference</foreign_table>
<foreign_field>uid_foreign</foreign_field>
<foreign_sortby>sorting_foreign</foreign_sortby>
<foreign_table_field>tablenames</foreign_table_field>
<foreign_match_fields>
<fieldname>myImages</fieldname> <!-- CAUTION!! Replace "fal" with the variable name of this field! -->
</foreign_match_fields>
<foreign_label>uid_local</foreign_label>
<foreign_selector>uid_local</foreign_selector>
<foreign_selector_fieldTcaOverride>
<config>
<appearance>
<elementBrowserType>file</elementBrowserType>
<elementBrowserAllowed>gif,jpg,jpeg,tif,tiff,bmp,pcx,tga,png,pdf,ai,svg</elementBrowserAllowed>
</appearance>
</config>
</foreign_selector_fieldTcaOverride>
<foreign_types type="array">
<numIndex index="2">
<showitem>--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,--palette--;;filePalette</showitem>
</numIndex>
</foreign_types>
<minitems>0</minitems>
<maxitems>10</maxitems>
<appearance>
<useSortable>1</useSortable>
<headerThumbnail>
<field>uid_local</field>
<width>45c</width>
<height>45</height>
</headerThumbnail>
<showPossibleLocalizationRecords>0</showPossibleLocalizationRecords>
<showRemovedLocalizationRecords>0</showRemovedLocalizationRecords>
<showSynchronizationLink>0</showSynchronizationLink>
<useSortable>1</useSortable>
<enabledControls>
<info>1</info>
<new>0</new>
<dragdrop>0</dragdrop>
<sort>1</sort>
<hide>1</hide>
<delete>1</delete>
<localize>1</localize>
</enabledControls>
<createNewRelationLinkTitle>LLL:EXT:cms/locallang_ttc.xlf:images.addFileReference</createNewRelationLinkTitle>
</appearance>
<behaviour>
<localizationMode>select</localizationMode>
<localizeChildrenAtParentLocalization>1</localizeChildrenAtParentLocalization>
</behaviour>
<dce_load_schema>1</dce_load_schema>
<dce_get_fal_objects>1</dce_get_fal_objects> </config>
我的字段名称是 myImages。所以变量名设置正确。 我的代码和示例之间的唯一区别是最后两行。 但是当我删除这两行时,什么都没有改变:
<dce_load_schema>1</dce_load_schema>
<dce_get_fal_objects>1</dce_get_fal_objects>
在我的模板中,我使用此代码来获取我的图像。
<f:for each="{dce:fal(field:’myImages’, contentObject:contentObject)}" key="n" as="fileReference" iteration="iterator" >
<f:if condition="{n}==0">
<f:then>
<a href='<f:uri.image src="{fileReference.uid}" treatIdAsReference="1" />' rel="gallery" title="Terrassendach" class="" >
<f:image src="{fileReference.uid}" alt="" treatIdAsReference="1" class="img-responsive cgallery" />
</a>
</f:then>
<f:else>
<a href='<f:uri.image src="{fileReference.uid}" treatIdAsReference="1" />' rel="gallery" title="Terrassendach" class="" >
</a>
</f:else>
</f:if>
</f:for>
也许有人知道我做错了什么。
谢谢大家。
【问题讨论】:
-
检查
typo3temp/logs/下的日志文件,它应该在日志条目中包含字符串20170309155903dbbf0d11,以发现您的错误。 -
谢谢,不知道。所以我发现 Exception: {"exception":"InvalidArgumentException: The argument \"each\" was registered with type \"array\", but is type \"string\" in view helper \"TYPO3\\CMS\ \Fluid\\ViewHelpers\\ForViewHelper\" in \/homepages\/7\/d82759675\/htdocs\... 但我不知道为什么。我在示例中做了同样的事情。
-
这通常意味着
<f:for>循环的each参数的语法不正确。在您的情况下,myImages周围的单引号看起来很奇怪 - 它们不是正常的 ('),而是其他的东西(向前勾号?) -
你是对的,但奇怪的是错的。但现在我得到另一个代码错误:代码:20170309184102e296c357 - {"exception":"TYPO3\\CMS\\Fluid\\Core\\Parser\\Exception: Namespace could not besolved. This exception should never be throw! in \/主页\/7\...
-
这意味着您在流体模板的开头缺少
{namespace x=Foo\Bar\ViewHelpers}声明。