We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
Subscribe: RSS
  • I modified your file download snippet to grab descriptions from a csv (default is descript.ion) file(that holds descriptions for all files in that directory)
    And uses an optional chunk template to display the list.

    ? Added to snippet call:
    [!FileDownload? &getFolder=`directory` &tplList=`chunkname`!]
    


    Chunk Example:
    <table>
        <tr><th>Filename</th><th>Description</th><th>Filesize</th><th>Date</th><th>Link</th></tr>
    <hr>
    <tr>
        <td>[+filename+]</td>
        <td>[+description+]</td>
        <td>[+sizetext+]</td>
        <td>[+date+]</td>
        <td><a href="[+link+]">Download</a></td>
    </tr>
    <hr>
    </table>
    


    Todo:
    * Add the alternate row colours
    * Add Description /Comments editing, downloads counter.
    • Waow that was fast !!!
      This community amazes me, really lots of talented and dedicated people, you’re the man !

      And with placeholders and template chunk, there’s icing on the cake too grin

      Really great team work guys !
        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l&#39;outil id
      • Quote from: stempy at Mar 01, 2006, 08:27 AM

        [!FileDownload &getFolder=`directory` &tplList=`chunkname`!]

        Small typo, the call is missing the question mark as per below

        [!FileDownload? &getFolder=`directory` &tplList=`chunkname`!]

        Checking it out now, looking good smiley
          [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
        • Instead of getting a text file and reading it for the descriptions etc, why not use a chunk, then it can be edited from the manager. You could even have an argument to let the user specify the chunk (or tv or whatever).
            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
          • Hey Stempy, having some troubles with the snippet.

            1. It is not generating the correct link for the URLs, it needs to add a trailing / to the directory

            http://domain.com/assets/files/resourcesFilename.pdf should be /files/resources/Filename.pdf

            [EDIT]
            Links work if you call snippet with a trailing slash
            [!FileDownload? &getFolder=`directory/` &tplList=`chunkname`!]
            [/EDIT]

            2. Can’t get the filedesc.ion file working. The chunk works fine and it puts the date, filesize etc on the page, but it gets that from the files not the .ion file.

            I found the format for the file in the snippet:
            Filename,Description, Comment, file count

            So I have a file called Test.pdf with the following entery in the filedesc.ion

            Test.pdf,Test PDF file, Just a test file, 0

            Any ideas?
              [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
            • I recently made a similar snippet for my site to just show filelistings. It has some extra features (and misses some of this one smiley ). I will just list them here for reference. If interested I could put up the code so it can be integrated (code is still a bit messy, but it works).

              - Sort by filename, date, size or extension
              - Sort ascending or descending
              - Show only selected extensions
              - Show icons based on file extension (.doc files will have Word icon, .pdf will have Acrobat icon etc...)
              - Delete files (for selected webgroups)

              I have one pending request from the website manager and that is to have the possibility to rename files. Right now she has to delete the file and upload it again. (I use it in combination with the fileupload snippet posted somewhere else on this forum)
              • Mitch,
                I like the sound of some of the things you have in your code. Go ahead and post it if you don’t mind us taking a look.

                Kyle


                Also... See my original post for an updated version.
                • Yeah I second that +1

                  It would just be awesome !
                  Never mind the code is not perfect clean, don’t worry it will get cleaned up that’s the beauty of collective time and intelligence !
                    .: COO - Commerce Guys - Community Driven Innovation :.


                    MODx est l&#39;outil id
                  • - Show icons based on file extension (.doc files will have Word icon, .pdf will have Acrobat icon etc...)

                    Oh yea, I like that, can you tell it the location of the ICON cos I already use one for PDF’s and love to keep the theme going

                    So make that +1 smiley

                      [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
                    • Quote from: kjaebker at Feb 28, 2006, 05:19 PM

                      ***** Update 03/01/06 ******
                      After seeing the comments here and some of the work done, I have updated the FileDownload Snippet.

                      I added the code for usign a template, thanks to Robin for getting that going.
                      I also added the ability to get a description from a chunk (Great idea Susan), so you can update the info in the manager.
                      The ability to have alternating odd/even row highlighting is still there as well.

                      I also uploaded examples of the display template and the description chunk.
                      *******************



                      I get the following error when I call the updated snippet with [!FileDownload1_1?&getFolder=`assets/files/resources`!]

                      Parse error: parse error, unexpected ’&’, expecting T_VARIABLE or ’$’ in /home/emanz/public_html/manager/includes/document.parser.class.inc.php(691) : eval()’d code on line 102
                        [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