Collect contact name and email before file download

In some instances, you may want to collect your contact’s name and email address before allowing a file download. Here is one method I use, which requires the zem_contact_reborn plugin.

  1. Download the zem_contact_reborn plugin
  2. Install and activate

In an article (write tab), enter the following:

<txp:zem_contact mailto="your_email@example.com" thanksform="file_download">
<txp:zem_contact_text label="Name"  />
<txp:zem_contact_text label="Organisation" /> 
<txp:zem_contact_email />
<txp:zem_contact_submit label="Get File />
</txp:zem_contact>

Place the above code in your article and save. Change the email address to your own.

Create the file_download form

You may download your file  by clicking <a href="http://yoursite.com/file_download/6" title="some title">HERE</a>.

Create the form as type misc and save. Edit according to your requirements, and be sure to change the file id number.

2 Comments - Comments RSS Feed

Ryan Gardner
# 19 March 2009

Great tip! I have a client who wanted this, but didn’t want people to have to click on the link to download the file — just wanted to have it download as soon as the user submitted the form. So I worked a little magic with the great smd_if plugin.

I did this before txp:variable came around so this might be possible without the smd_if plugin …

In the article the first line of the zem_contact plugin specify the file you want to download like this:

<txp:zem_contact to="your_emai@example.com" redirect="/download?file=27">

Then I created a section called “download” with this code between the <head> and </head> tags:

<txp:smd_if field="urlvar:file" operator="defined">
<meta http-equiv="refresh" content="1; url=/file_download/{smd_if_file}">
</txp:smd_if>

Then, just for good measure, I put the download link down in the body of the page just in case the user’s browser doesn’t refresh:

<txp:smd_if field="urlvar:file" operator="defined">Thanks for your request. The download of your file should start now. If it doesn't, please <a href="/file_download/{smd_if_file}">Click Here</a>
<txp:else />
No download file was specified.
</txp:smd_if>

I’m sure this could be refined, but it seems to work well.

Google
# 28 February 2011

great code!

Add a comment

Required

Required, not displayed

Optional

Use Textile Help to style your comments