GDPR privacy disclaimer
This form will send me your email address and your IP address.
If you don't want that, don't use this form!
UDT that outputs the current season
Previous article Next articleAt our community website I made a header with a changing photo of our village and the surrounding area. I made four folders with photos, one for each season. With a User Defined Tag I read the date and determine what season it is and set it in a Smarty string. With that I change the output of the photo gallery path.
In the CMSMS forum we discussed a similar UDT, I improved the code and will show it to you here.
How to use
Create a new UDT with the name "season" and the content:
$limits = array (
'/12/21'=>'winter',
'/09/21'=>'autumn',
'/06/21'=>'summer',
'/03/21'=>'spring',
'/01/01'=>'winter');
foreach ( $limits as $key => $value ) {
$limit = date('Y') . $key;
if ( time() >= strtotime($limit) ) return $value;
}
You can use this UDT in your page or template like:
Working example
Code:
Output:
The current season is: winter
Working example
Comment Form
ReviewManager
ReviewManager
0 Comments
No comments yet...