André Luiz André Luiz - 10 months ago 82
PHP Question

Phalcon PhP - how to change the view dynamically

I'm working in a website where part of it I have the static html, so I created a layout and in it I'm inserting the static content using views. My problem is as this website has many pages I feel wrong creating an action for each url. So I implemented the controller below:

class PageController extends ControllerBase
public function initialize(){
$this->view->setLayout( 'website' );

public function indexAction ($url=''){
if($url == 'about')

When I set the controller view to render $this->view->pick('page/about'); it doesn't insert the view in the template. It renders only the view.

Is there a way to render the view within the layout, and is there a better approach to what I'm doing?

Thanks for any help


To load a template you should use


instead of $this->view->setLayout( 'website' );

By using $this->view->pick('page/about'); you are overwriting the layout set by $this->view->setLayout( 'website' );, resulting in only seeing the page/about layout.