During development of the upcoming, yet-to-be-released version of FoundationX, a requirement popped up to list users in a staff directory. This is from the sample contact page provided by Zurb as a Foundation Add-on, so it seemed like maybe this wasn’t an uncommon requirement. Curiously doesn’t seem to be anything in the MODX Extras Repo that does this - until now.
What’s in the Package?
The getUserProfiles Extra includes a Snippet to get user profile information which you can format with any tpl Chunk that you define. It also includes an output modifier that generates the Gravatar Url for an email address. You can install via Package Manager, or download it here: http://modx.com/extras/package/getuserprofiles
To use the getUserProfiles snippet:
The above will print an array of up to 5 active users’ profiles because no tpl Chunk is defined.
This one will output formatted user profile information for up to 20 users from User Group ID 1, regardless of active state. It might look something like this (depending on the users in your site, of course)
Note: the value passed to
[[+website]] is stripped of url scheme for consistency, so you must prefix with a valid scheme for links to work, like this:
To use the gravatarUrl output modifier:
[[+email]] is a valid email address the above will generate the gravatar URL for the img src attribute.
That’s it! Hope you find it useful. Vive la MODX!
**UPDATE Dec.1,2013: Added getResourcesAuthor to the package, which is a simple wrapper Snippet for getResources. It will take a MODX User ID as a URL parameter (by default the key is ‘author’) and return only Resources created by that user. Handy for blogs, if you’re not using Articles.
**UPDATE: It’s been brought to my attention that there’s a snippet called ‘pdoUsers’ in the pdoTools package that does pretty much the same thing, only faster :P The caveat is that it returns extended fields as a JSON, whereas with getUserProfiles you can access it with the placeholder
[[+extended.attribute_key]]. For performance however, pdoTools seems to be kicking butt. There’s plenty of new and interesting additions to that package like ‘pdoSitemap’ and ‘pdoCrumbs’…but that’s another blog post ;)