Display content if month_tag = Current Month
2 posts by 2 authors in: Forums > CMS Builder
Last Post: July 2, 2019 (RSS)
By JeffC - June 25, 2019
Hi
I have a PillBox list field called month_tag. Each of the months are listed.
I would like to display certain content based on the current month of the year.
The below code works as required. But how do I replace $month_tag = array ('6'); so that this dynamically entered from month_tag:values?
<?php foreach ($promotion_placeholdersRecords as $record): ?>
<?php
$month = date('m');
$month_tag = array ('6');
if (in_array ("$month", $month_tag)){
echo "<br />June is the month :)";
} else {
echo "<br />The month is not June";
}
?>
<?php endforeach ?>
This is my attempt, but it doesn't work.
<?php foreach ($promotion_placeholdersRecords as $record): ?>
<?php
$month = date('m');
$month_tag = array ($record['month_tag:values']);
if (in_array ("$month", $month_tag)){
echo "<br />June is the month :)";
} else {
echo "<br />The month is not June";
}
?>
<?php endforeach ?>
By daniel - July 2, 2019
Hi jeffncou,
You should be able to achieve this with the listValues_unpack() function, by replacing this:
$month_tag = array ($record['month_tag:values']);
With this:
$month_tag = listValues_unpack($record['month_tag:values']);
Give this a try and let me know if it works for you!
Thanks,
Technical Lead
interactivetools.com