Hi!
So I have a custom field in one of my channels that has 7 checkboxes - one for each day of the week. The output of the custom field {job_schedule} is parsed as “Sunday|Tuesday|Friday” etc.. depending on which boxes are checked.
I want to display specific HTML based upon these individual options, but the only way I could think of to do this was using strpos..
Is there a better way?
Here’s what i’ve got….
<?php
$job_schedule = '{job_schedule}';
$sunday = 'Sunday';
$monday = 'Monday';
$tuesday = 'Tuesday';
$wednesday = 'Wednesday';
$thursday = 'Thursday';
$friday = 'Friday';
$saturday = 'Saturday';
$sundaytest = strpos($job_schedule, $sunday);
$mondaytest = strpos($job_schedule, $monday);
$tuesdaytest = strpos($job_schedule, $tuesday);
$wednesdaytest = strpos($job_schedule, $wednesday);
$thursdaytest = strpos($job_schedule, $thursday);
$fridaytest = strpos($job_schedule, $friday);
$saturdaytest = strpos($job_schedule, $saturday);
if($sundaytest === false){
?>S <?
} else {
?><span class="orangeglow">S </span><?
}
if($mondaytest === false){
?>M <?
} else {
?><span class="orangeglow">M </span><?
}
if($tuesdaytest === false){
?>T <?
} else {
?><span class="orangeglow">T </span><?
}
if($wednesdaytest === false){
?>W <?
} else {
?><span class="orangeglow">W </span><?
}
if($thursdaytest === false){
?>T <?
} else {
?><span class="orangeglow">T </span><?
}
if($fridaytest === false){
?>F <?
} else {
?><span class="orangeglow">F </span><?
}
if($saturdaytest === false){
?>S <?
} else {
?><span class="orangeglow">S </span><?
}
?>