I kind of threw this together, so it's almost certainly not correct, but it ought to get you started.
The more proper method would be to create three HTML chunks with
placeholders for the content: GalleryChunk and PhotoSetChunk, and PhotoChunk.
and do something like this in the snippet:
/* GalleryChunk:
<div id="gallery">
[[+sg.PhotoSets]]
</div>
PhotoSetChunk:
<div class="photosets">
<h2>[[+sg.PhotoSetTitle]]</h2>
[[+sg.Photos]]
</div>
Photochunk:
<div class="photos">
<a rel="lightbox[]"
href="[[+sg.PhotoUrlMedium]]"
title="sg.PhotoTitle >"
<img src="[[+sg.PhotoUrlSquare]]"
'alt="[[+sg.PhotoTitle]]"
title="[[+sg.PhotoTitle]]" />
</a>
</div>
[[ShowGallery? &galleryTpl=`GalleryChunk` &photoSetTpl=`PhotoSetChunk &photoTpl=`PhotoChunk`]]
<?php
/* ShowGallery snippet */
/* Get the Tpl chunks */
$outerTpl = $scriptProperties['GalleryChunk'];
if (empty($outerTpl)) {
return 'Could not find ' . $scriptProperties['PhotoChunk'] . ' chunk.';
}
$photoSetTpl = $scriptProperties['PhotoSetChunk'];
if (empty($photoSetTpl)) {
return 'Could not find ' . $scriptProperties['PhotoSetChunk'] . ' chunk.';
}
$photoTpl = $scriptProperties['myPhotoTpl'];
if (empty($outerTpl)) {
return 'Could not find ' . $scriptProperties['myPhotoTpl'] . ' chunk.';
}
$galleryContent = "";
foreach ($ph_sets['photoset'] as $ph_set) {
$innerContent = "";
$photoset_id = $ph_set['id'];
$photos = $f->photosets_getPhotos($photoset_id);
foreach ($photos['photoset']['photo'] as $photo) {
$fields = array();
$fields['sg.PhotoUrlMedium'] = $f->buildPhotoUrl($photo, 'medium');
$fields['sg.PhotoTitle'] = $photo['title'];
$fields['sg.PhotoUrlSquary'] = $f->buildPhotoUrl($photo, 'medium');
$fields['sg.alt'] = $photo['title'];
$fields['sg.title'] = $photo['title'];
$innerContent .= $modx->getChunk($photoTpl, $fields);
}
$ph['sg.PhotoSetTitle'] = $ph_set['title'];
$ph['sg.Photos'] = $innerContent;
$galleryContent .= $modx->getChunk($photoSetTpl, $ph);
}
$output = str_replace('[[+sg.PhotoSets]]', $galleryContent, $outerTpl);
return $output;
---------------------------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
MODX info for everyone:
http://bobsguides.com/modx.html
[ed. note: BobRay last edited this post 14 years, 8 months ago.]