UDT that outputs the current season

  Previous article Next article  

At 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 (

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:

<img src="{uploads_url}/images/{season}.jpg" alt="It is {season}!" />
<div class="{season}"></div>
{Gallery dir="header-photos/{season}" action='showrandom' number='1' template='header'}

  Working example

<p>The current season is: <b>{season}</b></p>

The current season is: winter

  Working example

Buy Me A Coffee

  Show related articles:

  Comment Form


Click here to open the form



No comments yet...

Buy Me A Coffee

CMS Made Simple - Tutorials, Tips and Tricks - CMSMS

UDT that outputs the current season

  Article optimized for CMSMS 2.x

  Last tested in: CMSMS 2.2.19
  Last updated: 10-06-2019
  Comments: 0

Buy Me A Coffee


Ads help me to help you! Thanks!

Ads help me to help you! Buy products from these advertisers!