douyi8408 2016-11-20 20:14 采纳率: 0%
浏览 36
已采纳

带有DCE的自定义内容元素中的单个文件

I installed DCE for custom content elements.

I would like a first div tag set conditionally including the filename. This should do it, but it doesn't - why?

  <f:if condition="{f:count(subject: {dce:fal(field:'bgImage', contentObject:contentObject)})}==1">
      <f:then>

        <f:for each="{dce:fal(field:'image', contentObject:contentObject)}" as="fileReference" iteration="iterator">
            <f:if condition="{iterator.isFirst}">
                <div class="element slide vertical-center picture{f:if(condition: '{field.isWhite} == 1', then: ' white')}" img-fill="{f:uri.image(src:'{fileReference.uid}',treatIdAsReference:'1')}" selectable>
            </f:if>
        </f:for>

    </f:then>
    <f:else>

        <div class="element slide vertical-center{f:if(condition: '{field.isWhite} == 1', then: ' white')}" selectable>

    </f:else>  
  </f:if>

What I need:

I defined a FAL property in DCE and if a file is set, the 'div' should be

<div class="element slide vertical-center picture" img-fill="FILEPATH" selectable>

if not it should be

<div class="element slide vertical-center" selectable>

I did not find a netter solution than this structure:

<f:for each="{dce:fal(field:'image', contentObject:contentObject)}" as="fileReference" iteration="iterator">
    <f:if condition="{iterator.isFirst}">
        <!-- render image by fileReference -->
    </f:if>
</f:for>

I already found the inline notation

{f:if(condition:'{filepath} != EMTPY',then:' picture')}

But how do I check for EMPTY in fluid?

{f:if(condition:'{filepath}',then:' picture')}

When I correctly understood Urs in the comments.

What do I miss?

  • 写回答

3条回答 默认 最新

  • douyanjing0822 2016-11-21 12:46
    关注

    I found a "solution" on my own:

      <f:for each="{dce:fal(field:'bgImage', contentObject:contentObject)}" as="fileReference" iteration="iterator">
    
        <f:if condition="{iterator.isFirst}">
    
          <div class="element slide vertical-center picture{f:if(condition: '{field.isWhite} == 1', then: ' white')}" img-fill-src="/fileadmin{fileReference.originalFile.identifier}">
    
        </f:if>
    
      </f:for>
    
      <f:if condition="<f:count>{dce:fal(field:'bgImage', contentObject:contentObject)}</f:count> < 1">
    
        <div class="element slide vertical-center{f:if(condition: '{field.isWhite} == 1', then: ' white')}">
    
      </f:if>
    

    What a mess. Compare to a PHP approach:

    <? if (count($image_references) == 1): ?>
    
      <div class="element slide vertical-center picture" img-fill-src="/fileadmin<? echo $file_references[0].originalFile.identifier; ?>">
    
    <? else: ?>
    
      <div class="element slide vertical-center">
    
    <? endif; ?>
    
    </div>
    

    And with this Fluid stuff you generate extreme overhead because after all you need a parser that parses the Fluid stuff. This parser is again written in PHP and muss be executed throughout to the frontend. That means everything has to be cached. But caching again is not good. The code is more easy. If you learn fluid you can't apply it somewhere else unlike PHP.

    What a bad idea this "Fluid"-System is!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)