Posts Tagged ‘snippet’

documentMan, MODx Document Management Snippet

Tuesday, November 18th, 2008

ModxIn 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.

MODx Snippet, CSS and Yahoo Weather Feed

Tuesday, September 2nd, 2008

Weather FeedI recently created a MODx snippet using a technique described on CSS-Tricks. This little bit of PHP code calls in the Yahoo Weather RSS feed and allows you to generate output that can be styled using CSS and your own icons. You can modify the first line of the snippet below to output weather specific to your zip code.

I first created the snippet ‘Weather’ ( Here is the snippet code.), then simply placed the snippet call on the appropriate page: [!Weather?!]. I then used my CSS document to style the output and created containers that would display the appropriate class ( Here is my CSS document). I created a div tag that carried my icon as a background image. I figured if Yahoo generated a tag that was unaccounted for in my CSS then my scheme would continue to display the appropriate text while leaving the adjacent background image undisplayed (as opposed to the little red Xs if I had used an image tag). Since I am using transparent gifs, I figured no one would be the wiser should this occur. Gif’s were derived from Nordic Weather.

You can see it in action on the Batesville, Arkansas Area Chamber of Commerce website.