EETemplates.com

ExpressionEngine Templates Free Pro Tutorials EE EECMS

On-Air now type schedule

Posted in Template Code

For now this is going to have to be a quick blog post. I will try and come back and fill in the details next week but I have a deadline tonight for this site and need to get it done. Once I feel it is flushed out I will move it to the tutorials section…. Make sure to let me know what you think.

Basically I needed a way to display a certain Radio Personality on the home page of a Radio Station website depending on the time of day. I just worked this up and have not seen it in action so… YMMV

Basically I created drop down list custom fields within the same Custom Field Group as the Persons bio and picture. The first custom field is the start time the second is the stop time. They are whole numbers from 0-24 representing the hours using Military Time. So if a show starts at noon and runs to 2pm it would get the starttime value of 12 and stoptime of 14.

I then created a category group called 'Days of Week'. I know original eh? Anyway, this set got each of the days of week in order so that we could go in an select all of the weekdays quickly. I didn't want to have to use PHP to get the value of the category to pass to the weblog:entries statement so I worked up a quick condition statement. I know this site will not be changing once I set it up (famous last words right?) so I am confident in this.

{if '{current_time format='%l'}' == 'Monday'}
{assign_variable
:showtime='4'}
{if
:elseif '{current_time format='%l'}' == 'Tuesday'}
{assign_variable
:showtime='5'}
{if
:elseif '{current_time format='%l'}' == 'Wednesday'}
{assign_variable
:showtime='6'}
{if
:elseif '{current_time format='%l'}' == 'Thursday'}
{assign_variable
:showtime='7'}
{if
:elseif '{current_time format='%l'}' == 'Friday'}
{assign_variable
:showtime='8'}
{if
:elseif '{current_time format='%l'}' == 'Saturday'}
{assign_variable
:showtime='9'}
{if
:elseif '{current_time format='%l'}' == 'Sunday'}
{assign_variable
:showtime='10'}
{
/if} 

I then needed something to grab the content so I use this.

{exp:weblog:entries weblog='schedule' category='{showtime}'}
{if 
'{current_time format='%G'}' >= starttime && 
'{current_time format='%G'}' stoptime}
<h3>{title}</h3>
{body}
{
/if}
{
/exp:weblog:entries} 

Basically we are calling the content from the 'Schedule' weblog based on the category called showtime which is the day. So that is how we eliminate the weekend shows. Or if you had shows that changed daily then it would basically eliminate any shows except for what is scheduled for today. We then have a conditional statement that says if the current hour is equal to or greater than starttime and is less than stoptime then display the Title and Body content. This eliminates the shows outside of what is happening this exact hour.

Again, I literally just finished this but some of you on twitter were curious as to what I was cooking up. The next couple of days I may see something that requires changes or you may point out things that need to be fixed…

Tell me what you think….

 

Want to write a blog post? Just use the contact form on the submit page!

Comments

Be the first to leave a comment...

Tell us what you think...

Commenting is not available in this channel entry.
Follow on Twitter Subscribe RSS

Related Articles

Creating Installable Templates for ExpressionEngine 2

This is the second installment in our Creating installable templates tutorials for ExpressionEngine. In this post we are going to talk about the actual package that needs to be delivered to the end user and all of the associated files. Plus we even

Read More

Removing Index.php from the URLs of Expression Engine websites

For a long time now I have struggled with removing index.php from my EE websites. I have used a mix bag of the include/exclude method and add-ons that deal with making the include/exclude method easier.

Read More