What is FileLister?¶
FileLister is a dynamic file listing Extra for MODX Revolution. It allows you to list files within a directory, as well as securely browse through subdirectories.
- MODX Revolution 2.0.0-rc-2 or later
- PHP5 or later
FileLister was written by Shaun McCormick (splittingred) as a dynamic file listing component, and first released on June 30th, 2010.
Development and Bug Reporting¶
FileLister is stored and developed in GitHub, and can be found here: http://github.com/splittingred/FileLister
FileLister can be called via the Snippet tags, and passing a 'path' argument.
FileLister comes with one snippet:
|filelister.salt||A custom salt for the navigation.|
List all the files and directories in assets/downloads.
List only files in the 'assets/pdfs' directory.
List all files and subdirectories in '/docs/marketing', but don't allow file viewing or downloading except for users logged in and in the 'Marketing' or 'CEO' groups.
[[!FileLister? &path=`/docs/marketing/` &allowDownloadGroups=`Marketing,CEO`]]
Restrict file listings in 'assets/pdfs' to only PDF files:
[[!FileLister? &path=`assets/pdfs/` &hideDirectories=`1` &showExt=`pdf`]]
Sample Resource Content¶
This is a sample of HTML that you can put inside a Resource to output your content. You'll need to have the toPlaceholder property set to 'files' for this to work, and call your FileLister snippet uncached before this HTML.
<h2>Files</h2> <p>Current Path: <span>[[+filelister.path]]</span></p> <table> <thead> <tr> <th>Name</th> <th>Filesize</th> <th>Last Modified</th> </tr> </thead> <tfoot> <tr> <th colspan="3"> Files: [[+filelister.total.files]] | Directories: [[+filelister.total.directories]] </th> </tr> </tfoot> <tbody> [[+files]] </tbody> </table>