Hi,
first of all big thanks to the community and to the developers for this great product.
I have a module that adds a hook before page render to act as rest endpoints.
I added the hook with:
$this->addHookBefore('PageRender::renderPage', $this, 'endpoint');
Everything works fine except the returned json has the ouput unformatted.
I'm creating the json array with:
$page->setOutputFormatting(true);
$json = array();
foreach ($page->fields as $field) {
$json[$field->name] = $page->get($field->name);
}
$json['id'] = $page->id;
$json['name'] = $page->name;
$json['created_user'] = $page->createdUser->name;
$parentEvent->return = $json;
A page with a title
"Title between quotes"
will have its json title property as
title: ""Title between quotes""
Am I missing something or is this the expected behaviour?
I also tried searching for a Page method that returns the field formatted, but it seems only getUnformatted exists.
Thank you in advance.