We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Picking view

How is picking view exactly working?

I have project with modules (frontend, backend) and hiearchical templates ( {{ extends main.volt }} + blocks defined) - But I hope it has no influence on functionality.

class IndexController extends ControllerBase

    public function indexAction()
     // template exists and rendered automatically somehow

    public function testAction()
        return $this->view->pick('index/index');

Views are located:

  -  frontend
     + views
         * index
            # index.volt
         * main.volt  (layout)

Index is working fine as expected. But when I go to "/test" page it is not loaded -> browser is waiting for response until it crash. So probably some cycle there?

If I create template "test.volt" it is working fine, but I want to take advantage from shared templates.

Any hints? Thank you!

Btw. How can I somehow format texts here? At least force line breaks/paragraphs? ^-^



return $this->view->pick(array('index/index'));

Not working for me...

Suprisingly even "own" template can't be picked:

return $this->view->pick(array('index/test'));

But it will probably happen because of modular hiearchy used - everything is complicated and not really working there :(


khm...a u tried smth like? php setViewsDir('app/views/');

viewsDir is set properly... anyway the same problem i have also for fresh generated project without modules. So I quess it is just not working for hiearchical templates.

It seems to me that most of documented stuff works only for "standard" generated project skeleton - if you change this default project layout, you can tear your hair to make it working. Seems that phalcon is still far away from Symfony2 :(

I'm giving up and disabling implicit views.


// in controller render desired template
echo $this->view->render('index', 'index');

I am also removing modules as it is very hard for me to make everything work. I hope it will works better after fresh start :)