Hi folks
I tried to develop a simple page to render in the mian content. It should just display a googlemaps with marker from our users. I used the flarum-extension-generator, created a route, a view and added a file in src/content/map.php which has a __invoke method.
This method code:
public
function __invoke(Document $document, ServerRequestInterface $request)
{
$apiDocument = (object) array(
'data' =>
(object) array(
'type' => "map",
'id' => 1,
'attributes' =>
(object) array(
'id' => 1,
'slug' => 'test',
'time' =>
(object) array(
'date' => '2019-07-04 13:17:22.000000',
'timezone_type' => 3,
'timezone' => 'UTC',
),
'editTime' =>
(object) array(
'date' => '2019-09-29 13:06:14.000000',
'timezone_type' => 3,
'timezone' => 'UTC',
),
'title' => 'test',
'contentHtml' => '<p>hallo welt</p>',
'isHidden' => false,
'isHtml' => true,
),
),
);
$document->content = $this->view->make('hs-map::content.page', compact("apiDocument"));
$document->payload['apiDocument'] = $apiDocument;
return $document;
}
The content con the view is displayed, but I get the following js error:
map:197 Uncaught TypeError: Cannot read property 'next' of undefined
at e.n.parseResults (DiscussionList.js:188)
Because I just want to render html, I created the object $apiDocument myself and dont want to work with models. But this does not seem to work, because the DiscussionList is tried to load. How can this be resolved?
What is the best way to just make a database-call and put html into the main content area of my design?
Kind regards