In a previous post related to a MODx and jQuery photo gallery solution I had described the creations of a MODx snippet to dynamically return the contents of a given directory. As I had suspected in my previous post this solution works well with other document types and, with a few tweaks, is currently being utilized to return unordered lists of documents on some of our larger websites.
The Why
We have many instances in which our end users maintain lists of documents on their sites. This may be a list of meeting minutes, newsletters or even a list of images that may be styled into a photo gallery presentation. While the TinyMCE plugin does a good enough job allowing for content updating and list creation, we felt we could provide a faster, simpler user experience. Now, with the documentMan snippet, the only action needed is to upload the newest document into the appropriate directory and the unordered list is populated instantly with the new document.
The How
In order to take advantage of this functionality you will need to download the documentMan snippet code. Use this code to create a new snippet in MODx. Inside the document there is a example call that will look like [!documentMan? &Location=`FileName` &docSort=`sort`!].
The “Location” variable is intended to describe the directory inside of assets/files in which you would like to return the list of documents. The snippet code can be changed easily enough if you need it to return from the images directory instead of the files directory.
The “docSort” variable can be set to “sort” or “rsort” depending on how you would like your list ordered. You can use “sort” for alphanumeric sorting or “rsort” for reverse alphanumeric sorting. We figured with some consistent naming the list order could be controlled easily enough. I anticipate at some point we will write the code that will allow for items to be sorted by timestamp, but that will be added to our to do list at this stage of the game.
What Else?
As we have been working on this code it has occurred to us that while this is a quick and simple solution, in many instances more may be needed. What we are envisioning is developing a MODx module that will serve as a document filter. This would allow for files to not only be uploaded into the system, but would allow for file naming, tagging, and categorization while being found in the site search. Some of our initial steps in this direction have been promising and we look forward to providing each of these solutions back to the MODx community.


