We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4095
    • 372 Posts
    Quote from: kjaebker at Mar 03, 2006, 12:34 AM

    Brigsy, I looked at the source on your test page and think I found the problem. Did you add the [+image+] placeholder to your template? If not, you need to put that wherever you would like the image to show.

    Let me know if that helps.

    Kyle

    Yup, that was the issue, I did wonder about that, but saw nothing in the snippets instructions about an image placeholder. I just assumed it was hardcoded.

    Now to style it over the next few days.

    Cheers.
      [img]http://www.emanz.ac.nz/assets/images/logo/emanz-icon_16x16.gif[/img] Emergency Management Academy of New Zealand [br] http://www.emanz.ac.nz[br][br]MODx Sandbox Login: sandbox Password: castle [br]
      Admin Sandbox Login: sandbox Password: castle
      • 15987
      • 786 Posts
      I have updated the snippet with some new features. You can download it from the inital post.
      I can’t think of many other things to add so this is probably a final version. Let me know if you have any additional things that would be good to add or any problems with the code.

      Kyle

      Quote from: kjaebker at Feb 28, 2006, 05:19 PM

      ***** Update 03/06/06 ******
      I have updated the FileDownload Snippet with some new features.

      You can specify which user groups can download the files.
      You can specify the sort order (name,type,size,date) and ascending or descending
      You can set which file types you would like to show, i.e. if you only want png files to show in the list.
      You can give a user group the ability to delete files. There is a new placeholder for this [+delete+] for the template.

        • 19726
        • 239 Posts
        Sorry for the late reply, but better late than never wink

        I promised to upload my code, so here it goes. Some of the settings are hardcoded at the top of the snippet. Below a list of parameters, not all are documented in code so I do it here.

        // Path where the files are located that should be shown.
        $path=`/assets/documents/reports/`

        // $sort defines the sorting method. It can be ’filename’, ’size’, ’date’, or ’extension’
        $sortby = ’filename’;

        // $sortdirection defines if the files are sorted ascending or descending.
        // possible values are ’asc’ or ’desc’
        $sortdirection = ’desc’;

        // webgroups that can delete files
        $admingroups = "wugBeheer";

        //If set the snippet will wrap the output in a div with the specified name
        $wrapdiv = "filelist";

        //enable the show icons feature
        $showicons = 1;

        // Path to the icons. Naming convention of the images in this folder is extension.gif. So pdf.gif for pdf files etc...
        $iconpath = "/images/icons/";

          • 7923
          • 4,213 Posts
          Is there any "download manager", file linker or anything that has a download counter? DocMan has a download counter, but I’d need to have something simpler.. Would it be too much to request it into this snippet? smiley


            "He can have a lollipop any time he wants to. That's what it means to be a programmer."
            • 15987
            • 786 Posts
            I have been looking into a good way of doing this, and the only thing I can think is to create a table to store the download count. I will probably try to add this into the snippet at some point. If anyone has any other suggestions on how to do this, I would appreciate the comments.

            I was thinking of having two different counting systems, one that just keeps track of total downloads, and maybe another that will store the user, date and the file downloaded. That way you could track what your logged-in users are downloading. If I do both I would give you the option of choosing which counter to use in the snippet call.

            Let me know if this sounds like a good idea for the snippet.

            Kyle
            • I have seen this done with a text file, the text file has a line for each file with the filename and the number of downloads, the file gets read into an array (splitting each line on the delimiter as it’s read) and the appropriate number gets incremented, the array is exploded back into delimited lines, and the file written to disk. A database would do the same thing, but would require a more complicated setup procedure to create the table.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 28471
                • 48 Posts
                Quote from: sottwell at Mar 08, 2006, 08:33 AM

                I have seen this done with a text file, the text file has a line for each file with the filename and the number of downloads, the file gets read into an array (splitting each line on the delimiter as it’s read) and the appropriate number gets incremented, the array is exploded back into delimited lines, and the file written to disk. A database would do the same thing, but would require a more complicated setup procedure to create the table.

                Err, like the updated version i did. with the download count in it (just wasnt implemented) . This is fairly basic to implement, just provide a link to a download script, that increments counter, updates file, and forces download of specified file.

                  • 15987
                  • 786 Posts
                  Quote from: kylej at Feb 28, 2006, 05:19 PM



                  ***** Update 03/08/06 ******
                  I have put an updated version of the file download snippet out. This time there is a zip file for you to download. You can now track how many times a file has been downloaded and display it on the page. You can also use the snippet multiple times on the same page.

                  Due to the changes in this version I have a few extra files that need placed in a folder (filedownload) in your snippet directory. There are full instructions in the readme.txt file in the zip.

                  I am going to keep the older version as a download incase you do not want to include these extra files (It does not have the newest features though). The must recent version is in the zip.


                  I have put a new version out with download counting. Let me know if there are any problems with the new code.

                  Thanks for the counting ideas sottwell & stempy.


                  Kyle
                    • 6726
                    • 7,075 Posts
                    Waow, this snippet has add quite a bit of improvements since I last checked, great work guys grin !
                      .: COO - Commerce Guys - Community Driven Innovation :.


                      MODx est l'outil id
                      • 7923
                      • 4,213 Posts
                      Quote from: kylej at Mar 08, 2006, 07:56 PM

                      I have put a new version out with download counting.
                      WOW! That was fast, superb work! Thanks smiley


                        "He can have a lollipop any time he wants to. That's what it means to be a programmer."