Phalcon PhP - how to disable the main layout for an action -


i'm creating action in 1 of phalcon controller used generate print version of page. here print.volt layout:

<!doctype html> <html lang="en"> <head>     <title>print</title> </head> <body> <!-- begin page content --> <div class="container">     {% block content %}{% endblock %} </div> </body> </html> 

and view:

{% extends "layouts/print.volt" %} {% block content %}     here     <script type="text/javascript">         window.print();     </script> {% endblock %} 

it working, problem content generated inserted inside layout has {{ content() }} tag. @ end o page website menus, print.volt , view. know how can view inserted inside print.volt, without master layout. how can disable behavior?

thanks help!

two options come mind.

1) use simple view, can render template without layout:

$view = new \phalcon\mvc\view\simple(); $view->setviewsdir('path_to_your_views'); $html = $view->render('template-name', $params); 

this option handy when generating html email sending.

2) disable layout current controller::method

$this->view->setlayout(''); 

3) update: timothy recommended alternative (2)

$this->view->setrenderlevel(\phalcon\mvc\view::level_action_view); 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -