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.

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.



83.4k
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'
));