I'm trying to render just a layout but I just keep getting empty string out of
The idea is to get views/posts/details.volt render and get the output in a variable so I can output it as a json encoded data.
Here is my code
// It is not an ajax request if ($this->request->isAjax() === false) return $this->response->redirect("404"); // Don't render this method $this->view->setRenderLevel(View::LEVEL_NO_RENDER); // Clone view $view = clone $this->view; // Start cloned view $view->start(); // Change views dir $view->setViewsDir($this->getDI()->get("config")->directories->views); // Set render level $view->setRenderLevel(View::LEVEL_LAYOUT); // Render $view->render("posts", "details"); // Finish view $view->finish(); // Get rendered view echo json_encode(array("html" => $view->getContent())); unset($view);
Could anyone tell me what am I doing wrong?
I don't know if it makes any difference but I am using custom routing. Such as custom/post-slug resolves to