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

Issues to disable implicit views rendering

Hi everyone !

Once again I've got issues with disabling the automatic rendering. I really need to force the user to pick explicitly his view.

Have tried to use application->setImplicitView(false), but when i use this line, nothing shows up. I've even tried to use the SimpleView class but without any luck:

RuntimeException: Call to undefined method ::start()

Concerning the source code i've only generated the project using phalcon dev-tools.

Thanks by advance

edited Oct '16

You mean useImplitView ? It should work fine. Simple view can't be used with application. It's only for simple rendering, it's not for view service for application.

It's obviously that nothing shows up because setImplictView means exactly that nothing will be rendered automatically. When using it you need to return render yourself.

Are you doing pick like this: return $this->view->pick("panel/index");

edited Oct '16

Yes sorry useImplicitView(false)

Understood for SimpleView, that's not what i need to do as you told me thanks a lot on this one :)

And exactly i've called in my controller :

return $this->view->pick("main/index");

But it's still shows nothing, even i've got a file main/index.volt

If i comment in my services.php $application->useImplicitView(false) , everything shows up even without the picking (but that's what i'm trying to avoid)



145.0k
Accepted
answer
edited Oct '16

But pick needs to be used with implictView to ENABLED. If you want to use implictView setted to false then you need to use render method like: return $this->view->getRender("main", "index")

Implitctview is just automatic rendering. Pick method just selects view to render, not renders it, to have it automatically rendered you need implictView set to true.

A big thanks ! it was it i needed to user getRender() instead of pick() . This one was a little bit tricky. Really many thanks !

You can use pick, just enable implictView :)