We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16173
    • 14 Posts
    Any easiest way to do "download count"?

    Is there any easiest way to do download count?
    In both Modx way or the common JS/CGI way is OK for me.
    I’m not familiar with PHP, but I know much of Perl. smiley

    I found the FileDownload snippet, but seems it’s for download list,
    not suit my requirement.

    My requirements:

    1, The link to the file to be downloaded must be plain, that’s to say,
    http://mysite.com/somefile.zip is prefered,
    http://mysite.com/somescript.php?blahblah is not acceptable.

    2, I can add the download link anywhere, maybe in an article, maybe in
    a download page.

    3, Download count is a must. I prefer the counter stored in a plain
    text, but database is OK too.

    4, I can display/hide the counter beside the link.

    What I’ve thought to do is,

    1, Put an "onclick" event handler for the download link. The download
    link is really plain and not rewritten.

    2, In "onclick", send a request to a server side script to increase
    the counter and continue the download.

    3, For displaying counter in the web page, put some placeholder tag
    and use JavaScript to get and display the counter.

    This method heavily depends on JavaScript, so it’s not very accurate
    when the JS broken (due to the web browser or bad net connection, etc)

    Is there any better or simpler solution. It will be good if I don’t
    need to make this from scratch. Indeed I have very few web development
    experience.

    Any advice?

      • 29181
      • 480 Posts
      FileDownload also has a FileDownloadPlugin which will offer the ability to store the number of downloads either in a text file OR a database depending on your preference. I’m not sure about the plain link though.

      FileDownload also offers a parameter whereby you can select just a singular file for download &getFile

      You can find out more about it at http://www.muddydogpaws.com/development/filedownload/features.html

      Hope that helps,
      Taff
        Adrian Lawley: www.adrianlawley.com