Thanks for this thread. I was having the same problem as others. Using the GalleryItemTV is great but for output it is not flexible in situations where you want to show a thumbnail image or you want to customize the output to include the description. The best way is to use the GalleryItem snippet, but you need the ID of the gallery item as discussed here: http://modxcms.com/forums/index.php/topic,55962.0.html
I’ll show the example of how I solved this. I’m displaying news items on my home page with a link to read the full item. If there is an image associated with the item, a thumbnail of that image is displayed.
Assumptions: You are using this method for associating an image with a resource: http://rtfm.modx.com/display/ADDON/Gallery.Setting+Up+the+GalleryItem+TV
. In this example the image template variable is named "image
1. On the Home page, the getResources call:
<div class="header bot-bdr">
<h3>News & events</h3>
<!-- / header --></div>
<!-- / section --></div>
Notice that I do not include the processTVs parameter
2. The "tpl-news-intro" chunk:
<!-- news-intro template -->
<div class="inner news-intro">
[[!GalleryItem? &id=`[[!getPicId? &imageTV=`[[+tv.image]]`]]` &thumbWidth=`100`]]
<a href="[[+galitem.image]]" rel="enlarge">
<img src="[[+galitem.thumbnail]]" alt="[[+galitem.name]]" />
... continues (not relevant)
This is a bit tricky to follow.. this chunk is used by getResources but to display the image we call the "getPicId" snippet inside of the "GalleryItem" snippet. "getPicId" gives us the image that is stored in the "image" template variable. Then we pass some parameters to "GalleryItem" (thumbWidth) and put the placeholders below the "GalleryItem" snippet to format our output as needed.
3. The "getPicId" snippet:
(I’m sure there are ways to foolproof the code above, please advise!)
The gallery item data is stored in JSON format. This PHP function reads it and allows you to extract the info you are looking for by key name... handy! In this case, we just need to extract the ID of the gallery item and pass it to GalleryItem where we have full control over display.
I hope this is helpful.