We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 156
    • 2 Posts
    OK, I am a newbie on modx. I have set of various files to be downloaded by user. Some of them are pdf, some are rar, other are MS DOC format and so on.

    I would like to display a list, where each of these files will have title, author and an appropriate icon for each type of the file, ie. pdf icon for a pdf file, MSWORD icon for a MSWORD document and so on. I would also like to display a size of each file and include counter of downloads so far for each file. When user clicks on each file, it should start download the file.

    Example:

    [table]
    [tr]
    [td]Title[/td]
    [td]Author[/td]
    [td]Format[/td]
    [td]Size[/td]
    [td]# of Downloads[/td]
    [/tr]

    [tr]
    [td]C For Dummies[/td]
    [td]Stephen Davis[/td]
    [td]pdf (icone)[/td]
    [td]1.2MB[/td]
    [td]43[/td]
    [/tr]

    [tr]
    [td]TCP Administration[/td]
    [td]Brian Komar[/td]
    [td]rar (icone)[/td]
    [td]2.2MB[/td]
    [td]12[/td]
    [/tr]

    [tr]
    [td]SAP’s R/3 Apps[/td]
    [td]Wolfgang Weiss[/td]
    [td]zip (icone)[/td]
    [td]5MB[/td]
    [td]62[/td]
    [/tr]
    [/table]

    How can I do it using modx?

    Thank you for any help.

    Vladimir
      • 3749
      • 24,544 Posts
      You’d need a custom snippet to read the directory containing the files and create the display.

      There’s something similar in this thread that might get you started: http://modxcms.com/forums/index.php/topic,40550.msg245511.html#msg245511

      BTW, for some users, a link to a .doc or .pdf file will launch Word or Adobe Reader rather than give a download option. I don’t think there’s any way to stop this other than adding a content-disposition header to each downloadable file designating it as an "attachment." In MODx revolution, you can create a Static Resource for each file and set the content-dispo field to "attachment" but I dont know if there’s any way to do this in Evolution.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 4971
        • 964 Posts
        The other day I found this http://www.muddydogpaws.com/development/filedownload/features.html while
        looking for Wayfinder info, I have not used it yet but it looks wonderful and I am waiting eagerly to use it
        in a future project. Is not exactly what you need but hope it helps...
          Website: www.mercologia.com
          MODX Revo Tutorials:  www.modxperience.com

          MODX Professional Partner
          • 156
          • 2 Posts
          Thank you so much to both of you. I particularly like the FileDownload snippet. It seems to me it does exactly what I need smiley