v8.4: how to render view without a page

Permalink
Following this:

https://documentation.concrete5.org/developers/framework/routing/vie...

I need to render a my_package/views/test.php view
<?php defined('C5_EXECUTE') or die("Access Denied.");
foreach ($topics as $topic) {
    echo $topic . '<br />';
}

at a route my_page/topics
$view = new View('test');
$view->setPackageHandle('my_package');
$view->setViewTheme('elemental');
$this->set('topics', $topics);
$view->setController($this);
return $this->responseFactory->view($view);

but I get an error: "Call to a member function css() on null". If it's to do with "rendering them without a valid page (like in this instance) will cause an error", then how can I render my custom view on a themed page at that route?

linuxoid
 
linuxoid replied on at Permalink Reply
linuxoid
I also tried extending the controller as a PageController:
$template = PageTemplate::getByHandle('full');
$this->render('/test', 'my_package');
$this->setTheme('elemental');
$this->setThemeViewTemplate($template);
$this->set('topics', $topics);

In this case I do get the topics shown on an empty UN-themed page. Although I did set the theme and template the page is not themed.

Any idea, help anyone?

PS. The Documentation page is wrong:
$view->setThemeHandle(‘green_salad’);

the View class doesn't have the 'setThemeHandle' method