Convert a string to availability images

  Previous article Next article  

A simple and easy to use availability feature for CMS Made Simple™. A User Defined Tag (UDT) converts a comma seperated string of 0's and 1's into a list of images.

You can use it for i.e. opening hours of a store or an overview of soccer trainings.

  How to use

I will show you an explanation with three rows of images for store openings.

Create a UDT named i.e. "Availability" and with the content:

$stringlist = isset($params['stringlist']) ? $params['stringlist'] : '';

$strings = explode(',' , $stringlist);

foreach ($strings as $string) {
  echo '<img src="uploads/images/img_availability_' . $string . '.jpg" alt="" />';

Note: You probably need to change the image path in the code...

Add in the top of your Core::Page template:

{$stringlist1 = "{content block=stringlist1 oneline=true}" label='Availability Morning' scope=global}
{$stringlist2 = "{content block=stringlist2 oneline=true}" label='Availability Afternoon' scope=global}
{$stringlist3 = "{content block=stringlist3 oneline=true}" label='Availability Evening' scope=global}

And in the area where you want the availaility images in a page or another spot in the template:


  {Availability stringlist=$stringlist1}
  {Availability stringlist=$stringlist2}
  {Availability stringlist=$stringlist3}

In the image folder I have two images:

  named img_availability_0.jpg

  named img_availability_1.jpg

  Working example

I filled the stringlist fields with:

The generated output will be something like:





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

Convert a string to availability images

  Article optimized for CMSMS 2.x

  Last tested in: CMSMS 2.2.19
  Last updated: 23-06-2018
  Comments: 0

Buy Me A Coffee


Ads help me to help you! Thanks!

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