Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

render view inside layout multi


in my public/index.php i have

    $di->set('view', function() {

          $view = new \Phalcon\Mvc\View();

          $view->setLayoutsDir( MODULES_DIR . 'common' . DS . 'layouts' . DS);

          return $view;

    }, true);

then in my module.php i have

$di->get('view')->setViewsDir(__DIR__ . '/views/');

but in this case it renders view first, and then the layout.

My layout has html, head etc... and in my view i have my content. So I want my content inside my body tag.. :D

edited Sep '15

ok... for all the people who start working with phalcon ( i use 2.x.x ) just now...

my suggestion is for now to use this example:

because the one in phalcon/mvc obviously suck.

What i did is created a new module folder, copy paste from other modules, and deleted everything else ( execpt the configs ) and works well.

The one i mentioned, will work with multiple modules and layout/view based applications. I would like to remove Phalcony ( package ) from it, just so i can make another repo with few examples of how people should start their apps, but i am still learning the framework unfortunatly :(