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.

Channels, Categories and Current Time Conditionals

November 12, 2012 12:44pm

Subscribe [1]
  • #1 / Nov 12, 2012 12:44pm

    Steve Fairhurst

    168 posts

    Hello Folks,

    As per usual I have suggested an idea for a clients site and they loved it. I’m now struggling to make it work. I think I just need a fresh pair of eyes.

    Basically they do some classes and would like a little box displaying what is coming up. So I have a channel set up which holds the name of the class and the time the class runs from and too (this info is used also elsewhere). I have categories setup for the days of the week.

    I thought by using something like this:

    {if {current_time format="%D"} == "Mon" }
    {exp:channel:entries channel="timetable" category="11" order_by="entry_id" sort="asc" disable="pagination|member_data"}
    Channel stuff here
    {/exp:channel:entries}
    {/if}

    I would be able to control which day of the week will display i.e. if today = Monday I can display Tuesday.

    But it just doesn’t work, I’ve also tried the conditional in side the channel tag still nothing. So please any fresh idea’s would be great.

    Thanks

  • #2 / Nov 14, 2012 1:21pm

    Dan Decker

    7338 posts

    Hi Steve,


    If you want this in a block that’s part of an overall larger template? How about our old friend dynamic=“no”?

    You can also do some simple tests to see if the conditional is operating properly:

    {if {current_time format="%D"} == "Mon" }
    It is Monday!
    {if:else}
    It is not Monday.
    {/if}

    Cheers,

  • #3 / Nov 14, 2012 1:41pm

    Steve Fairhurst

    168 posts

    Hi Dan,

    I did add the “dynamic=“no” but the way I needed it to work it just wasn’t happening.

    What did discover is that if you change:

    {if {current_time format="%D"} == "Mon" }

    to this:

    {if '{current_time format="%D"}' == "Mon" }

    It works.

     

  • #4 / Nov 16, 2012 3:06pm

    Dan Decker

    7338 posts

    Hi Steve,

    I’m glad you found the right syntax. Thanks for sharing!

    Is there anything else I can assist you with?

    Cheers!

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

ExpressionEngine News!

#eecms, #events, #releases