Popup sign in

Permalink
The client wants visitors to be able to download pdf's but not until they have signed in. He wants a login modal to appear when they click on the pdf icon if they aren't logged in.

Is there a way to do this?

 
amiraleyvac replied on at Permalink Reply
If You put permissions on the block to not show to a guest. then non registered visitor cant download your file.
tonyswaby replied on at Permalink Reply
I don't want to hide the file just make them sign in to download it.
mnakalay replied on at Permalink Reply
mnakalay
You would have to create a template for your block in which you use JS and Ajax to:
1- grab the file's URL from the link clicked
2- prevent the link to be followed
3- check the user permissions for that file
4- allow the click to proceed if permissions check (file is downloaded)
5- show a login popup if permissions don't check

Optionally you might have to reload the page after login through the popup but maybe not.
tonyswaby replied on at Permalink Reply
sound like a lot o work:)

Can I just detect if someone is logged in and change the state of the link accordingly?
tonyswaby replied on at Permalink Reply
How I'd normally do this would be to hide and show buttons/links relevant to the users state. But that would be just straight php, I've no idea how to do that in C5.
tonyswaby replied on at Permalink Reply
Applying my approach there would be no need for an Ajax call if you could detect whether someones is logged in, I assume there would be a session set?

If there is a session value I could change html elements to make things visible or not. And obviously a link to a popup if required.

Simple stuff really, but I haven't a clue how you do that in C5?
mnakalay replied on at Permalink Reply
mnakalay
in C5 it's actually quote easy to detect if someone is logged in or not.

In your block's view or template do this
$user = new User();
if ($user->isLoggedIn()) {
    // do something
} else {
    // do something else
}