Any gated content module in drupal 7

308 views Asked by At

Could you anyone know is there is any gated content module in drupal. I want to do add form before downloading the PDF. Eg. https://www.hds.com/en-us/pdf/ebook/cio-guide-to-digital-transformation.pdf

content that requires the acceptance of some sort of agreement or transaction before their site-visitors can access particular types of content.

2

There are 2 answers

0
Lars Nielsen On

Another posibillity is to use Commerce File with the Drupal Commerce suite of modules. With that you can sell access to your files.

1
MilanG On

You can intercept link click from JavaScript:

<a href="..document path" class="confirmation">Download document</a>
...
<script type="text/javascript">
    var elems = document.getElementsByClassName('confirmation');
    var confirmIt = function (e) {
        if (!confirm('Do you agree...?')) e.preventDefault();
    };
    for (var i = 0, l = elems.length; i < l; i++) {
        elems[i].addEventListener('click', confirmIt, false);
    }
</script>

If you want to check something with server you can use AJAX call...

Of course, this way in this form can be avoided by entering direct path to document to browser.

A more secure way wold be to involve use .htaccess to intercept http requests to the document file, and call php instead. PHP should check if user confirmed and if he did serve document and if he didn't throw some message.