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, Sarkari Result 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? Pnr Status

What's the best practice for Phalcon here?Showbox

edited Mar '19

I think it makes the most sense to pick() the view in the controller, depending on the role of the user. Something like:

public function listAction(){
    switch($this->User->role){
      case GUEST:
        $this->view->pick('list/guest');
        break;
    case ADMIN:
        $this->view->pick('list/admin');
        break;
    case PRO:
        $this->view->pick('list/pro');
        break;
}

How you store them doesn't really matter. I'd probably make a folder for the action and put them all in there.

edited Apr '19

To your taste. I would do through the folder, so for me it is more convenient. Less extra action.