Skip to content

Instantly share code, notes, and snippets.

@svebal
Last active December 20, 2015 11:09
Show Gist options
  • Save svebal/6120647 to your computer and use it in GitHub Desktop.
Save svebal/6120647 to your computer and use it in GitHub Desktop.
<h3>Ferien im Monat <?php echo strftime ('%B' , get_post_meta($post_id , 'Date', true ) ) ?></h3>
<?php
$i = 0;
$nextPeriod = false;
foreach ($days as $day) {
$vacationDataJson = get_post_meta($day->ID, 'Ferien', true );
### Ist dies ein Ferientag? ###
if( strlen($vacationDataJson) > 0 ) {
$i++;
$vacationData = json_decode ( $vacationDataJson);
### damit die Liste nur beim ersten Durchlauf geoeffnet wird ###
if ($i == 1) {
print "<ul>";
}
### ersten Ferientag speichern
if ($i == 1 || $nextPeriod == true ){
$firstVacationDate = date ('d.m.' , strtotime( get_post_meta($day->ID, 'Date', true ) ) );
$firstVacationType = $vacationData->FERIENART;
} else {
$currentVacationType = $vacationData->FERIENART;
if($currentVacationType == $firstVacationType){
$lastVacationDayDate = date ('d.m.' , strtotime( get_post_meta($day->ID, 'Date', true ) ) );
} elseif($currentVacationType != $firstVacationType){
$nextPeriod = true;
print "<li>" . $firstVacationDate . " bis " . $lastVacationDayDate . " - " . $firstVacationType . "</li>" ;
}
}
### Liste schliessen ###
print "</ul>";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment