Support

Account

Forum Replies Created

  • Thank you for your help, I tried to use your code and it doesn’t seem to work quite yet. Also I made some modifications :

    <?php
    // get the entire repeater in a multidimensional array
    $repeater = get_field('agenda_test');
    // set starting month and count
    // we need a counter to know if we're on the first row
    $previous_month = '';
    $count = 0;				
    foreach ($repeater as $row) {
      echo "</br>";
      var_dump($row);
      // make sure that your date field is returning a valid date format
      // or this will not work
      $this_month = date('F', strtotime($row['date']));
      if ($this_month != $previous_month) {
         // month has changed
         if ($count > 0) {
           // close the previously opened container
           // the container is opened below						
           ?>
           </div><!-- .month -->
           <?php 
         } // end in count > 0 (i.e. not first row)
         // open a new container and display the month
         ?>
         <div class="month">
         <div class="the_month"><?php echo $this_month; ?></div>
         <?php
         // update previous month value for next loop
         $previous_month = $this_month;
       } // end if new month
       // output additional sub fields here
       // increment count
       $count++;
    } // end foreach row
    ?>

    And this what I get in return:

    array(2) { [“date”]=> string(10) “02/02/2019” [“texte_test”]=> string(42) “Premier texte de ce qu’il se passe ce mois” }
    February

    array(2) { [“date”]=> string(10) “15/02/2019” [“texte_test”]=> string(28) “Un autre texte pour février” }
    January

    array(2) { [“date”]=> string(10) “05/04/2019” [“texte_test”]=> string(53) “Un texte pour le mois d’acril, mais écrit avant mars” }
    May

    array(2) { [“date”]=> string(10) “10/04/2019” [“texte_test”]=> string(29) “Ce texte est pour le 10 avril” }
    October

    array(2) { [“date”]=> string(10) “02/03/2019” [“texte_test”]=> string(27) “Le jour de mon anniversaire” }
    February

    I guess I have to format the date in some way, though I don’t know how. Also, I want the months in french if possible….

  • I would have a repeater with subfields : 1)date picker 2)title 3)texte

    I then want to to group each row by month to get something like this :

    Month1
    day1 – title1 – text1
    day2 – title2 – text2
    Month2
    day3 – title3 – text3

    I think maybe something’s missing still, I will try what you proposed and keep you updated!

    Thanks

  • Tell me if I get this right : using your code, I would have first to extract the month of each date, then use usort replacing email with month, right?
    Then I guess I would have to loop through each month to get the other fields?

  • Hi feyfey,

    Thank you for your reply. I have to confess that I’m not very advanced in PHP. I understand the documentation on the link you provided, but I have no idea how to use it for my case.

    Could you help?

Viewing 4 posts - 1 through 4 (of 4 total)