We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Template for Action in "namespaced" controller

I have a controller SomethingController in namespace Somewhere, and an action indexAction in it. I put the index.volt template to the /views/somewhere/something/ directory, but this template doesn't shown by default. It shown only if I add the code

$this->view->pick('somewhere/something/index');

to the indexAction function body.

Why it doesn't work?

Phalcon 1.1.0.



98.9k
Accepted
answer

The parameter for pick must only have two parts: a subdirectory in views/ and the view to render.

$this->view->pick('somewhere/something/index');  //have 3 parts.

If you want to render the view related to an action you can make better a forward:

return $this->dispatcher->forward(array(
   'controller' => 'Somewhere\Something',
   'action' => 'index'
));