There are basically two ways people can obtain a link to download a file on my site. Going to the node where that file is attached is the first way. Your module replaces the old "direct HTTP" link with the link that goes through pubdlcnt.php so downloads can be counted.
However, the second way to obtain a link is found in a Views table which returns results for files according to various filters the user can choose from. One column in this Views table is "Direct Download", which gives the direct HTTP link to the file so the user doesn't have to go to the node page to download the file. This URL is unedited by PDC, and therefore these downloads are not counted. I can probably set the URLs in this column to contain the whole pubdlcnt.php path as a prefix, but I wanted to know if this was something you would want the module to do automatically. I'm not sure how commonly this occurs on Drupal sites.
Comments
Comment #1
pixture commentedWhat kind of URL is the "Direct Download" by Views table?
Can you give me some examples so that I can see why PDC does not touch(edit) the URL?
I would like to know if this is something that PDC can handle automatically or not.
Thanks,
Comment #2
Iritscen commentedThe field is type "Upload: Attached files", and the URL it returns looks like: http://example.site.net/sites/default/files/Attached_file.zip.
If you want to see the live site, I don't mind linking you to it at all; I was just hesitant to do it in a public thread so that it doesn't attract more wannabe hackers who search for Drupal site addresses.
Comment #3
pixture commentedThanks for the example.
The URL seems to be as same as other direct HTTP links.
I guess the reason why PDC does not touch the link is because when PDC module is invoked to alter the node contents upon displaying, the link URL is something different and View module will alter it after the PDC module is invoked and change the link URL to something like your example.
One thing I can think of is the weight of the modules. Drupal maintains weight of all modules in it's system table of the database and this weight determines the order of the modules to be invoked when a certain action (such as alternating the node contents) takes place.
So if you change the weight of PDC modules so that it comes AFTER all the modules, then it may fix the problem.
You can do it easily with the Utility module. Please give it a try to see if changing the module weight fix the issue or not. It could be a different issue and weight may do nothing with this issue, but this is a only thing I can think of right now.
If you put bigger number (postive value such as 1000), the PDC module will be executed after all other modules. With my server Views weight is 10 and PDC is 0 (which is default). So if you make the weight of PDC bigger than 10, PDC comes after Views. I hope this fix the issue.
Comment #4
Iritscen commentedUnless there is something else I need to do to make the new weights go into effect (besides hitting "Save" on the Module admin page, of course), it didn't work. I set PDC as high as 1000 (with Views being 10) and the "Upload: Attached files" fields are still unmodified by PDC. I would imagine that anyone who uses this particular field in a Views table will experience this issue. I'm sending you a PM with a link to my site just in case you see something that my description failed to convey.
Comment #5
pixture commentedI looked into the source code of Views module and found that the hook_nodeapi with 'alter' operation code is not called for the table list view. This is the hook where PDC module converts the anchor tag.
Therefore, it requires totally different approach. I will look into Views modules and their APIs more but it may take some time to come up with the possible solution.
Comment #6
Iritscen commentedI see. Perhaps the Views devs would consider adding the call to 'alter' if asked nicely? :-) I don't know if there is a reason for not allowing that operation to be performed on the table view so I don't know if this is a practical request to make of them. But it would be a lot easier than changing PDC, I imagine.
I think that I will solve the issue on my side by removing the Download Link column from my table. It only means another click and some scrolling for users to find the file attachment on the node page, and it will guarantee that they use the download link that is tracked by PDC.
Comment #7
pixture commentedI think this is a important thing and PDC should support this by all means based on the fact that Views is one of the most popular modules for Drupal. I am looking into it right now so please come back to check the status on this issue.
Comment #8
jolidog commentedI'm also very interested in this functionality, Thanks for your work on this module!
A workaround I tried was editing the url output on views só it would became something like this:
http://example.site.net/sites/all/modules/pubdlcnt/pubdlcnt.php?file=htt...
Acording with the example above, but this does not trigger the counting... Any other workaround you might think of?
subscribing...
Comment #9
Golem07 commentedany news on this? I also am in need of views integration since this basically is the main way I am listing files for download.
Comment #10
Golem07 commentedjust a short update/addition:
using a (cck) file field with panels seems to disable the public file count as well.
Comment #11
pixture commentedI am making some changes and improvements to support download counting on any fields in Views. This code change is done and seems to be working. It add download count link to the uploaded file (by upload module) or CCK filefield in any view (HTML list, grid, table). This is not a total Views integration, but a kind of way to walkaround the issue because of the way PDC works (PDC does not care where the download file anchor exists).
Anyway, this portion is done at my testing site and almost ready to go.
I am also adding Block support which is used to list top download of your selected period. I am in the middle of development and I am trying to release it by the end of this year. I am looking into total Views integration too but it seems to take more time and effort.
Comment #12
pixture commentedFixed by beta4