We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

How can I make set embed tag on a timer?

Development and Programming

Dennis's avatar
Dennis
10 posts
14 years ago
Dennis's avatar Dennis

I want to be able to set the embed tag on a timer so that my data will disappear from the page at a set time. Any easy way to wrap the embed tag to do this? I want to show the item on the page on Tues and Thurs, Other days item is off. Thanks Dennis

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
14 years ago
Mark Bowen's avatar Mark Bowen

Hi Dennis,

Totally untested but this might work :

{if "{current_time format="%l"}" == "Tuesday" OR "{current_time format="%l"}" == "Thursday"}

{embed="template_group/template_name"}

{/if}

Best wishes,

Mark

       
Dennis's avatar
Dennis
10 posts
14 years ago
Dennis's avatar Dennis

That makes sense, I’ll test to see what it does. Thanks!

       
Dennis's avatar
Dennis
10 posts
14 years ago
Dennis's avatar Dennis

Seems to be working, I’ll know tomorrow if it turns off. Thanks again!!

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
14 years ago
Mark Bowen's avatar Mark Bowen
Seems to be working, I’ll know tomorrow if it turns off. Thanks again!!

Excellent. No problem. Please do let me know if it works tomorrow. As I said before this was just an idea and not tested so would be interested in knowing if it does indeed work myself.

Best wishes,

Mark

       
Dennis's avatar
Dennis
10 posts
14 years ago
Dennis's avatar Dennis

It didn’t work. It did not turn off the embed.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
14 years ago
Mark Bowen's avatar Mark Bowen
It didn’t work. It did not turn off the embed.

Hmm that’s weird. Seemed to work when I just tested it now on my machine. Admitted I was just changing my system clock to see if it worked but I would imagine that it would do the same thing on a server.

Have you tried outputting the current day just to see if the server is set up correctly?

Best wishes,

Mark

       
Dennis's avatar
Dennis
10 posts
14 years ago
Dennis's avatar Dennis

Sorry, how do I output the current day?

       
Dennis's avatar
Dennis
10 posts
14 years ago
Dennis's avatar Dennis

This is what I was trying to do:

{if "{current_time format="%l"}" == "Tuesday" OR "{current_time format="%l"}" == "Thursday"}
    {embed='inc/tip-of-the-day'}
{/if}
{if "{current_time format="%l"}" == "Monday" OR "{current_time format="%l"}" == "Wednesday" OR "{current_time format="%l"}" == "Friday" OR "{current_time format="%l"}" == "Saturday" OR "{current_time format="%l"}" == "Sunday"}
    {embed='inc/commenter-of-the-day'}
{/if}
       
Mark Bowen's avatar
Mark Bowen
12,637 posts
14 years ago
Mark Bowen's avatar Mark Bowen

Still very weird because if I place that exact same code in a template then it all works as it should do for me. Again admittedly I’m changing the day using my System Preferences but I would have thought that this would be the same as on a server.

Have you tried with just that code above and nothing else in the template?

Also try just this :

{if "{current_time format="%l"}" == "Tuesday" OR "{current_time format="%l"}" == "Thursday"}
Tuesday or Thursday
{/if}
{if "{current_time format="%l"}" == "Monday" OR "{current_time format="%l"}" == "Wednesday" OR "{current_time format="%l"}" == "Friday" OR "{current_time format="%l"}" == "Saturday" OR "{current_time format="%l"}" == "Sunday"}
All other days
{/if}

Just to see if the correct text comes out. One other thing is you’re not using any sort of caching are you?

Best wishes,

Mark

       
Dennis's avatar
Dennis
10 posts
14 years ago
Dennis's avatar Dennis

I tested your code and the correct result displayed. No caching involved.

OK, I placed the code back in and its displaying the right embed. Last night after 12:33 AM PT it did not switch the embeds like I expected. I’ll let it run again.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
14 years ago
Mark Bowen's avatar Mark Bowen

Could be an issue with localised dates I guess?

Maybe it changed at 1:00 instead? Might be worth seeing if that’s it.

Best wishes,

Mark

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.