DIRECTORY Binding
What is the @DIRECTORY Binding?
The DIRECTORY binding reads the contents of a directory. This can really useful when you tie it into a List control widget, e.g. if you want to do something like give the user a list of logo images to choose for a page, or choose which mp3 file plays on a particular page. REMEMBER: it returns ALL contents of a directory, including all files and all directories - with the sole exception of directories prefixed with a period.
Usage
@DIRECTORY /html_root_folder/path/to/some_directory
If you are using the @DIRECTORY binding for your template variable [[*myTV]], you can easily imagine that your template code could have some stuff in it like:
<img src="[[*myTV]]" alt="" />
Additional Info
Can you filter which files are selected? E.g. using *.jpg? The following DOES NOT WORK:
@DIRECTORY /list/*.jpg # doesn't work!
There are PHP code snippets out there that emulate this functionality. See the following forum thread: http://modxcms.com/forums/index.php/topic,3124.0.html
Security
Depending on how the file is used on the page, it may pose a security risk. Be careful if you were using this binding to select JavaScript files to be executed. What if a user had the ability to upload (and thus execute) a JavaScript file? Also, always be wary of letting users see your directory structure.