Air-to-Air Function - ExpressionEngine

EE v2.5.3

I am trying to do the following:

  • 6 broadcasts (Mon-Fri)
  • 1 Radio Show (Sun)
  • Default setting (logo)

I would like 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
source share
2 answers

That should sort you out

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

Please note that I put Thursday in single quotes and replaced your time formatting with single quotes.

+1
source

I would recommend using a combination of Switchee and IFElse , both from Croxton, to make this analysis faster, as it is rather complex conditional. How about something like that, for example?

 {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} 

Also note that I adjusted the time by 1 minute - otherwise two conditions in the same set (because you use equal or less / more) can be true at the same time.

0
source

Source: https://habr.com/ru/post/1444918/


All Articles