HTML Block - Timebased content

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
Njit
Forum Members
Forum Members
Posts: 55
Joined: Wed Jun 25, 2014 9:03 am

HTML Block - Timebased content

Post by Njit »

i'm using Smarty for my website. I'm trying to show some different content based on the time of day. But i'm doing something wrong with the logic i think.

I want to use these 3 timeframes (based on 24 hour period)

morning: 0600 - 1200
Afternoon: 1200 - 1800
Evening: 1800 - 0600

My HTML Block looks like this:

Code: Select all

<!-- It is now {$smarty.now|date_format:"%H:%M"} --> 

{if $smarty.now|date_format:"%H" >= 06 and $smarty.now|date_format:"%H" < 12 }{Showtime show='7'} 
{elseif $smarty.now|date_format:"%H" >= 12 and $smarty.now|date_format:"%H" < 18}{Showtime show='8'} 
{elseif $smarty.now|date_format:"%H" >= 18 and $smarty.now|date_format:"%H" < 06}{Showtime show='9'}{/if}
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

Re: HTML Block - Timebased content

Post by paulbaker »

Your last elseif will never occur. Hours can never be bigger than 18 AND less than 6 at the same time.

You probably want to change the last AND to an OR.
To copy System Information to the forum:
https://docs.cmsmadesimple.org/troubles ... nformation

CMS Made Simple Geekmoots attended:
Nottingham, UK 2012 | Ghent, Belgium 2015 | Leicester, UK 2016
Njit
Forum Members
Forum Members
Posts: 55
Joined: Wed Jun 25, 2014 9:03 am

Re: HTML Block - Timebased content

Post by Njit »

Feeling stupid. Changed it to OR.
chandra

Re: HTML Block - Timebased content

Post by chandra »

Topic solved?

if yes please rename the topic ;) (add a [Solved] at the beginning).
Njit
Forum Members
Forum Members
Posts: 55
Joined: Wed Jun 25, 2014 9:03 am

Re: HTML Block - Timebased content

Post by Njit »

I have seen it running ok during the morning and afternoon. will see what it will do in the evening and then rename the topic :-D
Njit
Forum Members
Forum Members
Posts: 55
Joined: Wed Jun 25, 2014 9:03 am

Re: HTML Block - Timebased content

Post by Njit »

I see no option to edit/rename my startpost. But solved!
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: HTML Block - Timebased content

Post by Rolf »

You can accept the correct answer, topic will be marked solved automaticly
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
Njit
Forum Members
Forum Members
Posts: 55
Joined: Wed Jun 25, 2014 9:03 am

Re: HTML Block - Timebased content

Post by Njit »

Don't see a option to accept an answer either :)
Post Reply

Return to “The Lounge”