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

Calling Specific View

Is there a way to call specific view inside a function ? Like in CodeIgniter you have something like $this->load->view('somedir/someview', $data);



125.8k
Accepted
answer

The view object is stored in the Dependency Injector (DI), and can therefore be accessed the same as anything else in the DI. It's not clear in what context the function resides (ie: Model? Controller?) and the specific code to access stuff in the DI will vary.

However, once you have the View object, you do have access to all the functionality of the View object. I'm not sure what you mean by "call a specific view", but it is possible to force the rendering of a specific view template file. Look at the documentation for the View functionality, specifically "picking a view" https://docs.phalcon.io/en/latest/reference/views.html#picking-views



16.6k

Yeah, picking-views is what I needed :-) Thanks.