We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37914
    • 89 Posts
    Hi,

    Is there a way to list all the contents of a Media Source?
    I use the Dropbox Media Source (https://www.markhamstra.com/modx/2012/01/bringing-dropbox-to-media-sources/).
    I would like to display all files from that Media Source with FileDir (http://modx.com/extras/package/filedir).
    [[!filedir? &dir=`mediasource3` &filetip=`jpg,pdf,doc,docx,xls,pdf` &tplOut=`file-index-outer` &tpl=`file-index-row`]]

    If this is impossible because it relies on the Dropbox api, then it is out of the question..

    Thanx in advance!

    • It's possible. I've done it testing the Amazon S3 source that comes with MODX. I forget now how I did it; I'll see if I can dig it up, unless somebody else answers you first. Well, it's also obviously possible since you can view it in the Manager's file browser.
        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
        • 37914
        • 89 Posts
        Thanx for your reply.
        I will sure appreciate it if you do find out!!

        Quote from: sottwell at Apr 29, 2014, 03:21 PM
        It's possible. I've done it testing the Amazon S3 source that comes with MODX. I forget now how I did it; I'll see if I can dig it up, unless somebody else answers you first. Well, it's also obviously possible since you can view it in the Manager's file browser.
        • Hm. I'm finding all kinds of API functions for accessing a given modMediaSource object, but these are specific to the type of source. For example, in modFileMediaSource there are several functions for getting, editing, removing, uploading objects (files and directories), as well as getting the base path and other information from a given modMediaSource object.

          There is modFileMediaSource, and modS3MediaSource. I would presume your custom media source has its own class file with its own variations on these functions.

          I just thought I remembered a fairly simple way of listing the files, but this was a couple of years ago.
            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
            • 37914
            • 89 Posts
            Bummer.
            Thanx for your help anyway!

            Quote from: sottwell at Apr 29, 2014, 04:04 PM
            Hm. I'm finding all kinds of API functions for accessing a given modMediaSource object, but these are specific to the type of source. For example, in modFileMediaSource there are several functions for getting, editing, removing, uploading objects (files and directories), as well as getting the base path and other information from a given modMediaSource object.

            There is modFileMediaSource, and modS3MediaSource. I would presume your custom media source has its own class file with its own variations on these functions.

            I just thought I remembered a fairly simple way of listing the files, but this was a couple of years ago.
            • Ok, I've got this for you. A simple snippet to return the base path of a given Media Source, used as the property in FileDownloadR. Gives you a lovely list of downloadable links to files in your Media Source.

              The getSource snippet (very rudimentary):
              $mediasource = $modx->getObject('modMediaSource',array(
                     'name' => $source ));
              $mediasource->initialize();
              $sourceBasePath = $mediasource->getBasePath();
              
              return $sourceBasePath;

              And to use it with FileDownloadR:
              [[!FileDownload?
              &getDir=`[[listSource? &source=`files`]]`
              &browseDirectories=`1`
              &groupByDirectory=`1`
              ]]

                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
                • 37914
                • 89 Posts
                Thanx for your advice.
                Unfortunately this doesn't work for the Dropbox Media Source.
                It works for the normal Filesystem sources.
                • Hm. I was wondering about that; I tested it on a filesystem-type media source whose base path was outside of the web root, and it works as expected. I do have an Amazon S3 account; I'll start running some tests to see if I can get something working with that. I would presume that if I can get the S3 drivers to work, then your Dropbox drivers should work in a similar manner.
                    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
                    • 37914
                    • 89 Posts
                    Thanx Sottwell.
                    I do appreciate that!
                    • I'll try to get media source into FileDownloadR
                        Rico
                        Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
                        MODx is great, but knowing how to use it well makes it perfect!

                        www.virtudraft.com

                        Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

                        Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

                        Maintainter/contributor of Babel

                        Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.