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

Is there some way to override the main template (views/index.php)

I just started using Phalcon, and I love it! Great work.

Anyhow. My website has a section for users who are not logged in (landing page, registration, info pages, etc) and then the section for those who are logged in. Typically once I user has signed up, there will be no need to browse those pages anymore. For this reason, I want the main template to be that which will be used on all of the logged in pages. This means I need to swap out the main template on the few pages that do not require log in.

  • Phalcon by default uses views/index.php as the main template. Is there some why I can make it utilize views/outside.php in very specific scenarios?

I'm not seeing a method of doing this and controller-specific layouts sound inappropriate as the unautheticated section of the site may have a random number of controllers. The authenticated portion of the website and the authenticated portion are essentially different websites.

Thanks



33.8k

I have the same structure as you for users, but don't know how to override the default view (I don't think even you can). But I did a workaround using ACL, and redirecting to some view or another depending of its permissions (or logged user).



12.6k

I have the same structure as you for users, but don't know how to override the default view (I don't think even you can). But I did a workaround using ACL, and redirecting to some view or another depending of its permissions (or logged user).

I'm thinking maybe the easiest solution would just be the have all the unauthenticated pages in the same controller. If I can't replace the main layout, is there some way to simply disable it for that controller?



12.6k

Mmm... maybe setMainView()? https://docs.phalcon.io/es/latest/api/Phalcon_Mvc_View.html

Oh geez... it's the simple. Lol, thanks! I was thinking that the terminology for those highest level views was "Layout", so I looked right over that.

Thanks very much. Sorry about the silly question!



33.8k

Yeah, maybe it's simple, but I had to search in the docs for that, because I didn't know it also xD