小编Wed*_*dan的帖子

使用Matrix的操作时间

我正在构建一个企业目录,不仅希望发布营业时间列表,还希望发布业务目前是否开放营业.

在矩阵中,我有7行,row_1表示星期六的星期日row_7.所以我有两个问题.

  1. 这是可能的代码COULD是简洁的还是有更好的方法?
  2. 条件中是否存在缺陷,告知企业目前是否开放?它现在似乎工作,但没有经过严格测试.

    {!-- Hours of Operation --}  
    {exp:stash:set name="hours-of-operation"}
    The Current time is: {current_time format="%g:%i%a"}<br/>
       {hours_of_operation}
       {if row_count=="1"}Sunday{/if}
       {if row_count=="2"}Monday{/if}
       {if row_count=="3"}Tuesday{/if}
       {if row_count=="4"}Wednesday{/if}
       {if row_count=="5"}Thursday{/if}
       {if row_count=="6"}Friday{/if}
       {if row_count=="7"}Saturday{/if}
       {open_time format="%g:%i%a"} - {close_time format="%g:%i%a"}<br/>
       {/hours_of_operation}
    {/exp:stash:set} 
    {!-- Hours of Operation --}
    
    {!-- Are we open? --}
    {exp:stash:set name="are-we-open"}
    {exp:mx_calc expression='{current_time format="%w"}+1'}
        {!-- matrix --}
        {hours_of_operation}                
            {if row_count=="{calc_result}"}
                Today is: {current_time format="%l"}<br/>
        <strong>
                {if '{open_time format="%H%i"}' <= '{current_time format="%H%i"}' && '{close_time format="%H%i"}' <= '{current_time format="%H%i"}'}    
                We are currently …
    Run Code Online (Sandbox Code Playgroud)

expressionengine

11
推荐指数
1
解决办法
484
查看次数

标签 统计

expressionengine ×1