This is an original Drupal module that keep track of file download count.
The biggest different between Download Count module and this module is that this module works under the Drupal's public file system while Download Count module works under the Drupal's private file system.
First of all, let me briefly explain about the Drupal's two file systems.
Drupal's file system
- Public file system
Uploaded files are directly downloaded from the server using HTTP. Drupal does not have any control over this downloading process. The files are needed to be placed to the directory under the server's DocumentRoot directory so that it can be directly accessed.
All uploaded files can be downloaded by anyone, and even can be downloaded by tying the files URL directly without going through the download page. As default, Drupal uses public file system.
- Private file system
Uploaded files are placed to a directory where users can not directly download them. Drupal has to process the download request and handle it.
Usually you create a directly outside of the server's DocumentRoot so that the file can not be downloaded directly by specifying the URL. The special file path including '/system/file/...' is used for this file system. You can limit the download by roles, users, etc...
If you want a secure and more control over the files you distribute at your site, you'd better use the private file system with Download Count module.
Public Download Count module is intended for the following people:
- Those who needs to use the public file system for some reasons, and yet want to keep track of file download count.
- Those who want to keep track of download count of the files on different servers.
Key features
- It is desined to work under Drupal's public file system.
- It can count the download of the file on external servers.
- You can specify the valid extensions of the target files.
- You can see the yearly, monthly and daily download count for each file.
- You can export the download count data as a CSV format file.
- It does not modify the original contents.
Using Public Download Count module is similar to use external file download CGI program. The anchor HTML tag for a direct file download is automatically converted to use the external PHP script of this module on the fly instead of using Drupal's internal hook mechanism. This is totally different from the Download Count module although the functionality is similar. With this anchor tag conversion method on the fly, Public Download Count module can count the number of download of the files that are located on the external sites.
Installation
Download the module at the Public Download Count project page at Drupal.org. Then, extract the archive at the module directory of your site. Then, enable the module at the Administer > Site building > Modules page.If you install the module to neither (drupal-root)/modules directory nor (drupal-root)/sites/(your-sitename)/modules directory, then you may need to do the following extra steps to make this module work.
The external PHP script (pubdlcnt.php) may not work as it is depending on the installation directory. If you see any error message when you testing the file download with this module enabled, please edit the top portion of this file as follows:
Before
After
- // print "Error: Public Download Count module failed to work. The file pubdlcnt.php requires manual editing";
As you see above, delete the line that displays an error message and then change the next line with actual absolute path to the Drupal root of your server. Besides, this is just a example, and you need to replace 'absolute-path-to-drupal-root' with the real absolute path that matches to your server and Drupal installation.
How to use (1) Module configutation
Once the installation is completed, go to the Administer > Site configuration > Public Download Count page, and specify the file name extensions of the target files. Extensions are case insensitive.
That's all you need to do. Now, the module is ready to work.
How to use(2) View download counts
To view the download counts of files, go to the Administer > Reports > Public Download Count page. You will see the list of files and their total download count (see the example below).
Clicking file name will jump to the page(node) where you can download the file. To reset the download count of a file to 0, click the "Reset" link. To view the detail download count statistics of a file, click the "Details" link.
When you click the "Detail" link, you can see the yearly, monthly and daily download count of the file (see the example below).
How to use(3) Export download count data
You can export the file download count data as a CSV format (comma separated text format) file, which you can open with Excel and other spreadsheet programs later.
How to use(4) Display download count in nodes
As you can see the example below, Public Download Count module can display the total download count of the file right after the link to download the file.
If you are an administer, then clicking the download count will jump to the detail download count statistics page of the file.
You can show this total download count to any users (without the link to the statistics page).
To do this, go to the Administer > User management > Permissions and enable the "view total download count in nodes" checkbox for the role you want to allow.
How to use (5) Creates blocks
This modules can show top download file list of specified time period to a block. You can create as many blocks as you like at the module's configuration page. Once you specify the number of blocks you want to use, then the blocks are created. Go to the Blocks page and customize each blocks.
You can specify the number of items to be shown to a list. You can also select if you want to add anchor to nodes of which the files can be downloaded. For the time period of counting, you can select either one of Last Year, This Year, Last Month, This Month, Last Week, This Week, Yesterday and Today.
The block you creates would look like this.
Clicking file name will jump to the node(page) where user can download the file. You can also show the download count after the file name depending of the user role and permissions. You can assign the permission "view total download count in block" to the role you want to show the counter value.
Only the admin user have the count with the anchor to the statistics page of the file.
Technical Details
Public Download Count module works with any anchor tags that meets the following criteria.- The anchor tag must have URL with a file name at the end. It does not work with the anchor tags whose URL is a directory name
- The anchor tag must not have a query string. For example, the following anchor tag is ignored by the module.
<a href="http://example.com/prog.php?param1=XXX¶m2=YY">
- The anchor tag must have a file name with a valid file name extensions specified at the module configuration page.
- The anchor tag must not have a file path to the private file system (which includes /system/files in its path)
- The anchor tag must be in nodes, not in comments. This module does not handle anchor tags in comments.
- The anchor tag must not have "rel=lightbox..." attribute. (thickbox and shadowbox too).
NOTE: Public Download Count module conflicts with the image files that uses lightbox, thickbox and shadowbox. So currently they are excluded from the target.


Doesn't work with COntent Templates
Very good module, but it doesn't work with Content Templates (or content types created with CCK). Hope you can fix this.
It supports CCK
I'm using some content type created by CCK and filefield and the public download counter works OK with the files attached by the filefield module.
I need more detail information on your problem to fix it.
1) absolute path of the drupal root directory in the server
2) absolute path of the public download count installed directory
3) absolute path of a file that does not count
4) URL of the file (see the status bar when you move mouse over to the file download link).
5) confirm that the file name extension of the file is included in the valid extensions of the module settings page.
Thanks,
It supports CCK. but, sure
It supports CCK. but, sure thing, it doesn't work with Content Templates.
this is a php snippets in my node-*.tpl.php, pubdlcnt doesn't work!
I fix it as follows:
But it's too complex, and I don't know how to output counts.Hope fix this,thanks a lot :)
Views
This module looks very promising and might be just what i need. I do have two questions though.
1) Can the text output by the module into the node be edited and, if so, how?
What i mean is that just (number) is a bit sparse and uninformative. I would like it to say something like "this file has been downloaded # times"
2) Is it possible to use this module's data through views? I am making a, tabled, overview of files uploaded by user, i would like it to show visitors to see how many times a file has been downloaded and to allow them to sort by most/least downloaded.
regards,
a curious user
With beta4 release, the issue
With beta4 release, the issue (2) is supported, while (1) is not yet.
You can edit the module source file pubdlcnt.module to change the counter form (number) to something different.
I will make it customizable with the next release.
Great job
Thank you for such a useful module :)
However, how can I utilize the counter info (the issue #2) in my custom view (The Views module)?
Thanks a lot
Hey,
Just wanna say thank you very much!!!!!!!!!! this is even better than I expected!
works great with filefield thanks a lot