We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Render Level in Micro Views

I have a problem setting render level for views in micro framework. For front page I want the the "default" render level, which is main layout > action view (I dont use controller layout). But for some ajax page I don't want to have any layout at all but still keep the view in the views directory.

$app->get('getVideo/{id}', function($id) use($app) { //the AJAX
   $app['view']->setRenderLevel(\Phalcon\Mvc\View::LEVEL_NO_RENDER);
   echo $app['view']->getRender('main','video'); //I want this to only load "video.phtml" not "views/index.phtml" then "video.phtml"
});

$app->get('/', function() use($app) {
   header("Content-Type: text/html; charset=utf-8");
   echo $app['view']->getRender('main','front');
});

It keeps loading the main layout inside the 'video.phtml' on getVideo. What can I do?



14.7k

Hi,

I believe this might be the answer to your issue: https://docs.phalcon.io/en/latest/reference/views.html#picking-views