4

EE v2.5.3

I'm trying to accomplish the following:

  • 6 Radio Shows (Mon-Fri)
  • 1 Radio Show (Sun)
  • Default Setting (Logo)

I'd like to be able to tell EE the following:

If Monday - Friday AND
0600 - 1000 
Morning Show

else if

1000 - 1500
Midday Show

etc etc..

else if
Sunday AND
0600 - 1200
Sunday Show

else if 
1700-1900
Sunday Night Show

else 
Default display of Logo

My (non-working) Example:

<div id="in_studio_now_content" class="container_4">

{if
    '{current_time format="%l"}' == Thursday AND
    '{current_time format="%H%i"}' >= '1000' AND
    '{current_time format="%H%i"}' <= '1700'
}

<div class="showContainer">
    <img src="http://placehold.it/75x75" class="container_1" />
    <div class="showInfo left">
        <h5>The Midday Show</h5>
    <p>with Jenn</p>
    <p class="timeslot">Weekdays 10:00 - 3:00 pm</p>
        <div id="facebookLike">F like 32k</div>
    </div>
    <a href="#" class="showLink container_3">More about this show &rsaquo;</a>
</div><!-- /show -->

{/if}

</div><!-- studio content -->
4

2 回答 2

1

这应该对你进行排序

{if
'{current_time format='%l'}' == 'Thursday' &&
'{current_time format='%H%i'}' >= '1000' &&'{current_time format='%H%i'}' <= '1700'}

请注意,我已将星期四放在单引号中,并将您的时间格式也替换为单引号。

于 2012-11-08T20:34:15.113 回答
0

我建议使用来自 Croxton 的SwitcheeIFElse的组合来加快解析速度,因为它是一个相当复杂的条件。例如,这样的事情怎么样?

{exp:switchee var="{current_time format='%l'}" parse="inward"}
    {case value="Monday|Tuesday|Wednesday|Thursday|Friday"}
       {exp:ifelse parse="inward"}
           {if '{current_time format="%H%i"}' >= '0600' AND '{current_time format="%H%i"}' <= '0959'}
               Morning show
           {if:elseif '{current_time format="%H%i"}' >= '1000' AND '{current_time format="%H%i"}' <= '1459'}
               Midday Show
           {/if}
       {/exp:ifelse}
     {/case}
     {case value="Saturday"}
         Do the same sort of thing for Saturday
     {/case}
     {case value="Sunday"}
         Do the same sort of thing for Sunday
     {/case}
{/exp:switchee} 

另请注意,我已将时间调整了 1 分钟 - 否则,同一组中的两个条件(因为您使用的是等于或小于/大于)可能同时为真。

于 2012-11-08T20:37:23.293 回答