Support

Account

Home Forums Add-ons Repeater Field repeater dates arranged by months title Reply To: repeater dates arranged by months title

  • OK. figured it out.
    managed to change the dates to “pretty” and add the rest of the fields that i needed.
    the months name titles working… but i made them in a stupid way.
    maybe somebody can add a nice fix to it.
    hope it will help somebody as it helped me.

    
    <?php
    
    $repeater = get_field('vacation_repeater1');
    $order = array();
    $now = strtotime("now");
    $sortedDate = array();
    
    foreach( $repeater as $i => $row ) {
        $order[ $i ] = $row['start_date'];
    }
    
    array_multisort( $order, SORT_ASC, $repeater );
    
    foreach($repeater as $row){
    
        $theDate = strtotime(str_replace('/', '-', $row['start_date']));
    
        if($theDate > $now){
            $theMonth = substr($row['start_date'],4 ,2);
            if (!isset($sortedDate[$theMonth])){
                $sortedDate[$theMonth] = array();
            }
            array_push($sortedDate[$theMonth], $row);
        }
    }
    
    foreach($sortedDate as $theMonth => $theDates){
    	 //echo $theMonth . '<br/>';
    if($theMonth == 01) {
    	echo 'Jan <br/>';
    } elseif($theMonth == 02) {
    	echo 'February <br/>';
    } elseif($theMonth == 03) {
    	echo 'March <br/>';
    } elseif($theMonth == 04) {
    	echo 'April <br/>';
    } elseif($theMonth == 05) {
    	echo 'May <br/>';
    } elseif($theMonth == 06) {
    	echo 'June <br/>';
    } elseif($theMonth == 07) {
    	echo 'July <br/>';
    } elseif($theMonth == 08) {
    	echo 'August <br/>';
    } elseif($theMonth == 09) {
    	echo 'September <br/>';
    } elseif($theMonth == 10) {
    	echo 'October <br/>';
    } elseif($theMonth == 11) {
    	echo 'November <br/>';
    } elseif($theMonth == 12) {
    	echo 'December <br/>';
    }
    
    foreach($theDates as $theDate){
    	//echo $theDate['start_date']. '<br/>';
    	$date = $theDate['start_date'];
    	$date_tour = date_i18n("l, F j, Y", strtotime($date));
    	echo $date_tour. '<br/>';
    
    	echo $theDate['flight_to_time']. '<br/>';
    	echo $theDate['flight_back_time']. '<br/>';
    	echo $theDate['price_standart']. '<br/>';
    	echo $theDate['price_standart_plus']. '<br/>';
    	echo $theDate['air_company']. '<br/>';
    	echo '<br/><br/>';
    }//$theDate
    
    }//$theMonth
    
     ?>