Last active
December 20, 2015 11:09
-
-
Save svebal/6120647 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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