Phalcon: View Structure for Multiple Roles

Hi. I have a project, where users have multiple roles:

define ('GUEST',0); define ('ADMIN',1); define ('PRO',2);

Depending on the role, I want to pull a different view in some cases. I'm wondering the best way to structure the folder/files for the views.

Should each role have a folder, and I look to see if the view exists/if not go to the next role? Or do I do this with file names ->index_admin.volt, index_pro.volt?

Hi Rocky inside the controller you can use $this->view->pick('the-view-name') to change the render file.

Other way you can do your own view service with auto select the file checking the role

Good luck

Honestly I don't think it matters - whatever makes the most sense to you. I say that because regardless of the method you choose, you'll still have to write your Controller or View code to point to the proper file. So just go with what works for you.

For what it's worth, I'd personally go with the filename convention, as you'd be making folders that only contain one file.