ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How To Show Element Only At Certain Times

February 06, 2009 4:20pm

Subscribe [2]
  • #1 / Feb 06, 2009 4:20pm

    454 Creative

    23 posts

    I have a feeling this will have a simple solution… but i just don’t know it!

    My client will have live video on their website at certain times:

    Saturday at 5pm, Sunday at 9:00am and 10:30am

    I would like to have an image show up on the homepage, but only at those times… say on Saturday from 5-6pm, and Sunday from 9-11am.

    Is there a method or extension that would let me do something like this?

    Thanks in advance.

  • #2 / Feb 07, 2009 3:49pm

    454 Creative

    23 posts

    I guess I could make a weblog for it, then place the image in an entry and set it as a reoccurring event with repeet…

    But it seems like there should be an easier way.

    Is it possible to use conditional statements with current_time?

    like: {if current_time > 5:00}IMAGE{/if}

    ?

  • #3 / Feb 07, 2009 7:12pm

    Kris Khaira

    38 posts

    You might want to check out the Repeet plugin. I think this post on SitePoint is also related to your question: Finding current show in recurring schedule w/PHP and MySQL.

  • #4 / Feb 09, 2009 5:41pm

    454 Creative

    23 posts

    Thanks Kris… I installed Repeet…. but couldnt get it to do what I wanted.

    Instead, I did a little more creative thinking and came up with this:

    {if ('{current_time format="%w"}' == '6' AND '{current_time format="%G"}' == '17') OR ('{current_time format="%w"}' == '0' AND '{current_time format="%G"}' >= '9' AND '{current_time format="%G"}' <= '11')}
    {exp:weblog:entries weblog="live" limit="1" show_future_entries="yes" show_expired="yes" dynamic="off"}
    {live_body}
    {/exp:weblog:entries}
    {/if}

    So that statement does something like: If it’s Saturday, in the hour of 5 pm, then show the graphic. OR if it’s Sunday, from the hours of 9 to 11, then show the graphic.

    I think it should work perfectly.

  • #5 / Feb 13, 2009 11:18am

    Kris Khaira

    38 posts

    No problem. I hope your code worked. What problem were you having with Repeet?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases