Looking to render a view output into a variable without the view actually displaying? You need to create a new instance of a view with a second paramter of false, and then continue to use this variable to set variables and view paths. When you call render, you can store the output in a variable and it won’t automatically display. If autoRender is true in your controller, you’ve got to set it to false before proceeding.
Here’s an example of storing the html of an element called ‘box’ with the variable of ‘text’ without the view displaying or outputting:
/* Make sure the controller doesn't auto render. */ $this->autoRender = false; /* Set up new view that won't enter the ClassRegistry */ $view = new View($this, false); $view->set('text', 'Hello World'); $view->viewPath = 'elements'; /* Grab output into variable without the view actually outputting! */ $view_output = $view->render('box');