Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Managin view #195

Closed
mrspartak opened this issue Nov 17, 2012 · 1 comment
Closed

Managin view #195

mrspartak opened this issue Nov 17, 2012 · 1 comment
Milestone

Comments

@mrspartak
Copy link

Have problem with filter json_encode

$app['controller'] = $view->getControllerName();
$app['action'] = $view->getActionName();
$view->setVar("app", $app);

in template

{{ app|json_encode }} //returns Unknown filter json_encode

And would be nice, if you look at #183. This is really very important feature for Volt.

So and I have one more question.
I've created BaseController that extends Phalcon/Mvc/Controller, and when I want to get current controller name I need to manage dispatcher in di and call

$this->dispatcher->getControllerName()

besides to call just
$this->view->getControllerName() //returns empty string

or just
$this->getControllerName() // of course undefined method

Maybe there is another way to get information without calling dispatcher?

@phalcon
Copy link
Collaborator

phalcon commented Nov 17, 2012

$this->view->getControllerName() return nothing in the controller because the the view component doesn't know what controller/action must be rendered. This only happens after the dispatch loop has ended.

Only the dispatcher has the information you need,

Also, there seems to be a bug with the json_encode filter, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant