Extended Tags for display events in calendar

Hello, Im using statamic 3 extended tags for display the calendar. here is my code for reference

My code is:

public function example($format = 'Y-m-d')
    {   
      //  $arrayObject=array();
        $a=array();

        $arrayObject[] = $this->context->value('event_date');
        $interval = new DateInterval('P1D');
            $realEnd = new DateTime($arrayObject[0]['end']); 
            $realEnd->add($interval); 
            $period = new DatePeriod(new DateTime($arrayObject[0]['start']), $interval, $realEnd); 
            $events=[];
            foreach($period as $date) {                  
                $array['events'][] = $date->format($format);  

            }
            array_push($events, $array);
            print_r($events[0]['events']);

       ?>

print_r output is comming like:

Array ( [0] => 2020-11-21 [1] => 2020-11-22 [2] => 2020-11-23 ) Array ( [0] => 2020-10-11 [1] => 2020-10-12 [2] => 2020-10-13 [3] => 2020-10-14 [4] => 2020-10-15 )

my script is like:


var eventData = [{ date: " <?php echo $events[0]['events']; ?>", badge: false, title: "Example 1" }, ];

###getting the error is like:

ErrorException
Array to string conversion

In inspecting console shows:

Uncaught SyntaxError: Invalid or unexpected token
VM13064:119 Uncaught ReferenceError: jQuery is not defined
    at VM13064:119
(anonymous) @ VM13064:119
(index):331 Uncaught ReferenceError: PhpDebugBar is not defined
    at (index):331
(anonymous) @ (index):331

Expected output is:

// calendar init
  var eventData = [
    { date: "2020-10-09", badge: false, title: "Example 1" },
    { date: "2020-10-04", badge: false, title: "Example 2" },
    { date: "2020-10-24", badge: false, title: "Example 3" },
    { date: "2020-11-07", badge: false, title: "Example 4" },
  ];
  $("#my-calendar").zabuto_calendar({
    data: eventData,
  });

I'm trying to achieve to highlight the event dates in the calendar.

Note: Here we have multiple entries and date ranges for each entries.

Please, anyone, help me to get all entries data in a single array, or display all dates in the calendar.

>>>>>>> Unanswered <<<<<<<
0 Replies
1 Follower