Jump to content

While using the PHP page 'fetch-event.php' in root directory 'Text (Multilanguage)' filed is not working correctly


SIERRA
 Share

Recommended Posts

I need to get json out put to configure calendar events. I am using fullcalendar ( https://fullcalendar.io/ ). To configure event url I am using a PHP page. If I configure a url like http://wwww.mysite.com/news-events/events/ this is not working. So I created a PHP page in root and accessing the same using http://www.mysite.com/fetch-event.php. The code is as below

..........

 var calendar = $('#calendar').fullCalendar({
        editable: false,
        events: "http://mysite.com/php/fetch-event.php",
        displayEventTime: false,

............

While using the PHP page 'fetch-event.php' in root directory 'Text (Multilanguage)' filed is not working correctly. The PHP code is as below.

$events_pages = $pages->get(1085);

$events_array = array();

$events_pages = $pages->get(1085);

foreach ($events_pages->events as $event) {

$events_detail = array();

$event_start_tmp = strtotime($event->event_start);
$event_start = date('Y-m-d',$event_start_tmp);

    $events_detail["id"]=$event->id;
    $events_detail["title"]=$event->title; //This is text - Multilanguage field
    $events_detail["start"]=gmdate("Y-m-d",$event->event_start);
    $events_detail["end"]=gmdate("Y-m-d",$event->event_start);

array_push($events_array, $events_detail);
  
}
print_r($events_array);

Out put is

Array ( [0] => Array ( [id] => 1411 [title] => ProcessWire\LanguagesPageFieldValue Object ( [default] => School Resumes [chinese] => ) [start] => 2018-01-06 [end] => 2018-01-06 )

But I want the out as

Array ( [0] => Array ( [id] => 1411 [title] => School Resumes [start] => 2018-01-06 [end] => 2018-01-06 )

Please suggest how can I do this

Thanks

Edited by SIERRA
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...