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}' disable='member_data|pagination|trackbacks'}
{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….
In this video we will start with a blank slate and create a usable but simple layout to replace that which is found at Sean Smith’s Repatriate.me. This was not meant to be a end all be all tutorial but rather just a quick post about some of the
Congratulations to Simon Cox who won the Flower Shop template (soon to be released). And Winston Graham who won the training materials from Train-ee.
Keep checking in as we will be giving away a forum module with our Legato template starting
This one is simple. Comment below whether you want a template (and which one) or training materials from Train-ee. Tomorrow afternoon at 5pm Central Standard Time we will do a drawing for each. Make sure to tell us which one and if it is a template
This is just the first of the give-a-ways so make sure to stay tuned. The video tells the tale! Oh and Princess Laurie won a free PhotoStudio template today by being the first person to Direct Message us her email. So make sure to add us to your
Related Articles