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

Login / Registration popup. How to handle that ?

Hello,

I am creating a webpage with few subpages. I want to create two popups for signing in and signing up, but I don't know how to do this without copying code through subpages. I think every popup should have a separate view and controller.

Am I right? What is the best practice to do it?

Regards.



33.8k
edited Jan '15

I would create two actions, one for sign up and other for sign down. Then, create in the popups a button that will submit to one of that actions.

They even haven't to be actions of a controller: just plugin's functions (remember that an action will be accesible in the URL unless you deny access in the ACL). Just remeber to access propertly to the session in the DI.

And for avoiding repeated code, use templates ( https://docs.phalcon.io/es/latest/reference/volt.html ).

You are probably using something like modal or fancybox for popup, and they both support creating popup with HTML returned by accessing an URL.

This means, popup can access specific action on one of your controllers. This action will render the form needed with a specific layout (without usual header/footer of your website, since you likely don't want them inside the popup).