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 view inside layout multi

Hello,

in my public/index.php i have

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

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

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

          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



85.5k
Accepted
answer
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: https://github.com/ovr/phalcon-module-skeleton

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 :(