Hi Friends,

I haven't found any where mentioning how to enable or configure the download count for the file located in an external server.
For example
I have two files on amazon cloud server one is
http://mycloud.s3.amazonaws.com/myfile.exe and
http://mycloud.s3.amazonaws.com/myfile.zip

I have a simple HTML button in my Drupal7 site pointing to this download URL.

Thanks in advance

Comments

pixture’s picture

Are these buttons in a block or node or views field? PDC module does not support anything other than these. In addition, PDC module only works with anchor tag. Please check this first.

Bright Web Design’s picture

Thank you so much for your reply.

Sorry for not mentioning about where I put the button,
The buttons I have created are in a block with full HTML filter.
The block is placed just below the top menu. (Highlighted region.)
I have also added the file extension "exe" in the file format settings.

Here is the code I have put in my block;


<div id="download-file">
<p><a href="http://mysite.s3.amazonaws.com/myfile.exe" title="Download My File For Windows"><img src="sites/all/themes/mytheme/images/windows-download.png" alt="Download My File For Windows" title="Download My File For Windows" /></a></p>
<p><a href="http://mysite.s3.amazonaws.com/myfile_mac.zip" title="Download myfile for Windows"><img src="sites/all/themes/mytheme/images/mac-download.png" alt="Download myfile for Mac" title="Download myfile for Mac" /></a></p>
</div>

Is there anything I have to do more to work this module?
Thanks in advance.

pixture’s picture

Sorry but what I told you is wrong. PDC module does not support anchor link in blocks because it requires node id (nid) for the record keeping purpose. Here's the way to walk around the issue (assuming you can use PHP filter).

In your block configuration page, select the PHP filter for the input format instead of Filtered/Full HTML. Then add the code something like below.

<?php
$html = <<< EOM
<div id="download-file">
<p><a href="http://mysite.s3.amazonaws.com/myfile.exe" title="Download My File For Windows"><img src="sites/all/themes/mytheme/images/windows-download.png" alt="Download My File For Windows" title="Download My File For Windows" /></a></p>
<p><a href="http://mysite.s3.amazonaws.com/myfile_mac.zip" title="Download myfile for Windows"><img src="sites/all/themes/mytheme/images/mac-download.png" alt="Download myfile for Mac" title="Download myfile for Mac" /></a></p>
</div>
EOM;
if (function_exists('pubdlcnt_filter')) { // PDC module is enabled
  print pubdlcnt_filter($html, 0);
}
else { // PDC module is not enabled
  print $html;
}
?>

The code above passes all your block HTML code to pubdlcnt_filter() function. pubdlcnt_filter() function will convert all valid anchors so that PDC module can trace the download count. With this code, you should be able to record the download count of the files in the blocks.

Second parameter of the pubdlcnt_filter() function is a node ID. In case of blocks, there's no node ID, so I used 0 as a dummy node ID.

Please give it a try.

Bright Web Design’s picture

That didn't produce any report of downloads.

What happens if I create a custom front--page.tpl.php and add my html download link button instead of block? Does that support this module?

Thanks for your kind help.

pixture’s picture

> What happens if I create a custom front--page.tpl.php and add my html download link button instead of block? Does that support this module?

You can pass any HTML code to pubdlcnt_filter() function from anywhere (block, static page generated by views, modules, theme templates). pubdlcnt_filter() just extract anchor tags included in the passed HTML code and convert them.

Bright Web Design’s picture

I am really sorry to say this, the one way you suggested me above with block didn't work at all.
Sorry for taking this much time to reply, I am in Japan and the situation was so bad here.

If you can give some other way to work this well, it would be greatly appreciated.

Thanks in advance.

Best Wishes

Bright Web Design’s picture

Title: How to count download from external server? » How to count download from external Amazon Cloud server?

Does anyone know how to make this module to count the downloads from Amazon Cloud Server which I linked from my Drupal site's Block.

If anyone can give me an idea to set this up would be greatly appreciated.

Thanks in advance.

Bright Web Design’s picture

It Works with block;

I just used the "block id" instead of "nod id".
Now I can see in the source code php has been added by the pdc module.
However I don't get any download count data on the report section. I think it's because of localserver
Let me try it on the live site.

Will be back with the result soon.

Thank you so much pixture

Bright Web Design’s picture

Version: 7.x-1.0 » 7.x-1.x-dev

Dear Pixture,

How I configured "pudlcnt" module

  1. Edited the pubdlcnt.php as mentioned to my site root.
  2. I have installed the latest dev version of the "pubdlcnt" module in my live site.
  3. Enabled PHP filter
  4. Added the above code (#3) with my "block id"
  5. Now I can see the the code shown below on my block.

However I can't see any download count statics on the report area of the "pubdlcnt" module.

<p>
<a title="Download My App for Windows" href="/sites/all/modules/pubdlcnt/pubdlcnt.php?file=http://mysiteroot.s3.amazonaws.com/app/app_sw/app_setup.exe&amp;nid=4">
<img alt="Download My App for Windows" src="sites/all/themes/mythemes/images/windows-download-app.png">
</a>
</p>

Is there anything else I should do to display the download count?
Also if you check the code above it says "nid=4" though I set the "block id" is that the reason for not displaying the result?
Is there anyway to enable this module to work with the "block id" too?

Looking forward to see some tips to work this with "blocks id".
Thank you so much

Bright Web Design’s picture

Version: 7.x-1.x-dev » 7.x-1.0
Priority: Major » Critical

I have tried everything but nothing shows the download count.
I can see the "(0)" count number always but nothing shows in the report section.

I have even created it on the page instead of block and still it doesn't work for me.

Please suggest me a solution to work this great module! I really need this module.

Best Wishes for your development works.

BenK’s picture

Subscribing