Forums / Developer / Page access with email

Page access with email

Author Message

Antoine Dubois

Tuesday 26 October 2010 12:39:44 am

Hi guys,

I have to developp something that can sound weird... or not.

My client want the anonymous users to enter their email adress to access a page. Those email adresses would be stored in a table.

Any clue on how I could realize that?

Thanks in advance.

Antoine

Nicolas Pastorino

Tuesday 26 October 2010 1:03:25 am

Hi Antoine,

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

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Antoine Dubois

Tuesday 26 October 2010 5:05:44 am

Hi,

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.

Hope it could help someone...

Cheers

Antoine

Nicolas Pastorino

Tuesday 26 October 2010 10:20:49 am

Hi Antoine,

Does this mean that for every page requested, the custom module/view is run ? I hope this is not the case, due to severe user-experience damages :)

Let us know,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Antoine Dubois

Tuesday 26 October 2010 11:09:36 pm

Hi Nicolas,

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?

Nicolas Pastorino

Wednesday 27 October 2010 1:53:26 pm

Alright, not too harsh with performances then.

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

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

eZ debug

Timing: Jan 18 2025 02:04:38
Script start
Timing: Jan 18 2025 02:04:38
Module start 'content'
Timing: Jan 18 2025 02:04:38
Module end 'content'
Timing: Jan 18 2025 02:04:38
Script end

Main resources:

Total runtime0.0209 sec
Peak memory usage4,096.0000 KB
Database Queries4

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 587.6875180.8516
Module start 'content' 0.00580.0075 768.5391101.8516
Module end 'content' 0.01330.0076 870.390678.6875
Script end 0.0208  949.0781 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002311.0906120.0002
Check MTime0.00115.3046120.0001
Mysql Total
Database connection0.00083.908610.0008
Mysqli_queries0.003516.662140.0009
Looping result0.00000.070720.0000
Template Total0.007234.310.0072
Template load0.00094.396810.0009
Template processing0.006229.893510.0062
Override
Cache load0.00062.971110.0006
General
dbfile0.003416.4522100.0003
String conversion0.00000.025130.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs