带有 v:iterator.random 的随机图像 |缓存问题 [英] Random image with v:iterator.random | cache issue
问题描述
我尝试使用 VHS(版本 2.4.0)RandomViewHelper v:iterator.random
输出 1 个随机图像.
这是我的代码:
{namespace flux=FluidTYPO3\Flux\ViewHelpers}{命名空间 v=FluidTYPO3\Vhs\ViewHelpers}<f:layout name="内容"/><f:section name="配置"><flux:form id="random-image" label="Random Image" options="{icon: 'Icons/Content/Example.gif', group: 'Joya'}"><flux:field.input name="classname" label="Classname"/><flux:form.section name="images" label="Images"><flux:form.object name="image" label="Image"><flux:field.file name="imagesrc" label="Image" allowed="png,jpg" maxItems="1" size="1"/></flux:form.object></flux:form.section></f:section><f:section name="预览">随机图片</f:section><f:section name="Main"><div class="random-image"><v:iterator.random as="img" subject="{images}">{img.image.imagesrc}</v:iterator.random>
</f:section>
我添加了 3 个图像进行测试,但它始终输出相同的图像.随机的输出被缓存.所以它在清除缓存后输出另一个图像.
我可以只为这行代码禁用缓存吗?
https://fluidtypo3.org/viewhelpers/vhs/2.4.0/Iterator/RandomViewHelper.html
解决方案是使用 VHS ViewHelper v:render.uncache
并使用不应缓存的部分创建一个部分.它不是最好的解决方案,因为您需要一个额外的文件.但现在我能想到的唯一其他方法是使用一些 Typoscript,这也是我想要避免的.
I try to output 1 random image with VHS (version 2.4.0) RandomViewHelper v:iterator.random
.
This is my code:
{namespace flux=FluidTYPO3\Flux\ViewHelpers}
{namespace v=FluidTYPO3\Vhs\ViewHelpers}
<f:layout name="Content" />
<f:section name="Configuration">
<flux:form id="random-image" label="Random Image" options="{icon: 'Icons/Content/Example.gif', group: 'Joya'}">
<flux:field.input name="classname" label="Classname" />
</flux:form>
<flux:form.section name="images" label="Images">
<flux:form.object name="image" label="Image">
<flux:field.file name="imagesrc" label="Image" allowed="png,jpg" maxItems="1" size="1" />
</flux:form.object>
</flux:form.section>
</f:section>
<f:section name="Preview">
Random Image
</f:section>
<f:section name="Main">
<div class="random-image">
<v:iterator.random as="img" subject="{images}">
{img.image.imagesrc}
</v:iterator.random>
</div>
</f:section>
I added 3 images to test, but it always outputs the same image. Edit: the output of random is cached. So it outputs another image after the cache is cleared.
Can I disable the cache just for this line of code?
https://fluidtypo3.org/viewhelpers/vhs/2.4.0/Iterator/RandomViewHelper.html
The solution is to use the VHS ViewHelper v:render.uncache
and creatre a partial with the part that shall not be cached. Its not the best solution as you need an extra file. But right now the only other way I can think of is to use some Typoscript, and thats also something I want to avoid.
这篇关于带有 v:iterator.random 的随机图像 |缓存问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!