Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
thg_if_time - output data depending the time of day
What is this plugin for?
This plugin will return true part of condition, if current server time is inside of set period.
Remember – this plugin works with time in 24h format!
Downloads
Attributes
Attribute | Default value | Description |
---|---|---|
debug | 0 | Output some debug info in the top of the page |
delim | : | The delimiter betwean hours and minutes (hours[*:*]minutes) |
time_start | 00:00 | The start of time period |
time_end | 23:59 | The end of time period |
time_now | server time | You can set any time as current to check how plugin will work, remember to use right delim |
hours_offset | 0 | Offset in hours from server time |
Examples
Here are some exaples to look what plugin can do.
Example 1
<txp:thg_if_time debug="1" time_start="00:00" time_end="01:15" hours_offset="-1">
<txp:title />
<txp:else />
<txp:site_name />
</txp:thg_if_time>
This code will output the title of current article, if current server time minus one hour is between 00:00 and 01:15. Beside this, you will se in the top of the page some debug info, like this:
Time is OK
hours_start : minutes_start – 00 : 00
hours_end : minutes_end – 01 : 15
hours_now : minutes_now – 1 : 09
Example 2
<txp:thg_if_time time_start="06 00" time_end="12 00" hours_offset="+2" delim=" ">
<p>Good morning, visitor!</p>
<txp:else />
<p>Good day, visitor!</p>
</txp:thg_if_time>
This code will greet visitor with good morning, if current server time plus 2 hours is between 06 00 and 12 00. If time doesn’t match, general greeting will appear. Also, in this example hours and minutes are seaprated by space (” “).
Example 3
<txp:thg_if_time time_start="22-00" time_end="23-00" time_now="22-26" delim="-">
<p>Now is evening...</p>
<txp:else />
<p>This text will not appear!</p>
</txp:thg_if_time>
Here manual setting of current time is used. else
part of condition will not appear without regard to current server time. You can use this attr with attr debug
to explore how this plugin works. Notice, that all times are set using custom delim
.
Credits
- Author: the_ghost
- Use this plugin any time of day and never be ill!
- Contact: ICQ#8458496, nemiga@gmail.com
Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?
Offline
#2 2008-11-26 03:50:41
- rsilletti
- Moderator
- From: Spokane WA
- Registered: 2004-04-28
- Posts: 707
Re: thg_if_time - output data depending the time of day
Nice! I’ll check this out immediately.
Offline
#3 2008-11-26 04:28:12
- rsilletti
- Moderator
- From: Spokane WA
- Registered: 2004-04-28
- Posts: 707
Re: thg_if_time - output data depending the time of day
Works nicely under RC1 for 4.0.7.
Offline
Re: thg_if_time - output data depending the time of day
rsilletti wrote:
Works nicely under RC1 for 4.0.7.
Glad to hear that :)
Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?
Offline