Convert a string to availability images
Previous article Next articleA 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:
$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:
{$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:
<h4>Morning</h4>
{Availability stringlist=$stringlist1}
<h4>Afternoon</h4>
{Availability stringlist=$stringlist2}
<h4>Evening</h4>
{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:
"0,0,1,1,1,1,1"
"0,1,1,1,1,1,1"
"0,0,0,0,1,1,0"
The generated output will be something like:
Availability
Morning
Afternoon
Evening
Comment Form
ReviewManager
ReviewManager
0 Comments
No comments yet...