Sounds like something you should handle through a javascript overlay or something, then store the status of email gathering as cookie (since this applies to anonymous users, you will hardly have another way to do it). I suppose email harvesting should happen only once.
Cheers !
--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board
Thanks for your answer but I wanted the emails to be stored. So I digged a little and it appears that a custom module is the easiest.
Here's what I did :
I created a emailtoaccess module and activated it.
Within a askemail view, I look in the session to see if the emailaccess is set, if yes, then I redirect to the page. Otherwize I show a template with a form asking an email address. The action of that form is a setemail view within which I validate the email (if not redirect to askemail), put that mail in session, store it in the db and then redirect to the restricted page.
No the view is not run each time the page is requested.
I did two simple operators, one to check if an email has been set in session and another one to redirect to the email form view.
In the restricted access page template, I call the first operator and if no email has been set, I call the second operator so the user is redirected to the email form.
Once the user filled his email, this email is put in session (a cookie is even created), and so next time I'll want to acces the page, the email form won't be displayed.
I think it's not provocating severe user-experience damages... what do you think?
If a cookie is set, you could go the JS way, externalizing the slight overburden to the client end : let the page load, immediately test the cookie from javascript, and redirect (still from JS) to the email-harvesting page if no relevant cookie was found. The one issue with this solution is that it solely relies on js, thus might not work if disabled on the user's browser.
Cheers !
--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board