Hi Wonderland. Any chance of a knowledge swap? I know haow to get a gallery going. Do you know how to give a new user permission to access the manager? I assumed the latter would be the easiest part of the whole process, but its got me completely stumped.
About the gallery. This is only one gallery. It uses a snippet and one chunk to automatically display the images in a folder whose name is entered in a TV for the page that the gallery will appear on. One home-made snippet, one chunk, one TV.
An example of the result appears here (but you could layout the photos any way you wanted):
http://secure.sitesdns.com/~epablo/regions-in-spain-for-villa-holidays/liebana/liebana-villas/rocio-villa-liebana.html
I already posted this to help the person struggling with multiple TVs for images. I will paste it in again here:
). I needed to get a gallery on the page and wanted a way to load the photos automatically so the client can just upload the photos to a folder and not worry about putting them on the page or assigning individual photos to separate TVs. It’s easy.
First, make space for the gallery on your page template. I want the photos to line up in two columns in a sidebar on the right but have the first photo double width, so I deal with that separately (and I have decided that that photo will always be called main.jpg (the main photo in the folder)). So in the template I put this:
<div id="gallery">
<ul><li><a href="photos/[[*photofolder]]/main.jpg"><img class="galleryphotobigger" src="photos/[[*photofolder]]/main.jpg" alt="[[*pagetitle]]" /></a></li>[[!gallerylist?&dir=`[[*photofolder]]`]]</ul>
</div><!-- end gallery -->
There I have one TV called photofolder which the client uses to specify the name of the folder with the photos for the gallery on this page (the folder is always a child of the parent "photos" folder). The rest of the items in the list are created by the gallerylist snippet. The name of the directory that the snippet will have to look for is passed to it in the dir variable.
Here’s the little snippet which finds the photos and loads them via a chunk:
$findme = 'main';
$files = glob('photos/' . $dir . '/*.*');
$output = '';
for ($i=0; $i<count($files); $i++)
{
$photo = $files[$i];
if(strpos($photo, $findme) === false) {
$output .= $modx->getChunk('fullgallerychunk', array(
'filename' => $photo,
));
}}
return $output;
My knowledge of PHP is utterly basic so that might not be the best way to do the job, but it works. It lists all the files (there must only be image files in the folder) except for the file entitled main.jpg. It outputs the name of the file to the filename placeholder in the chunk.
Then you just need a tiny chunk for the images, like so:
<li><a href="[[+filename]]"><img class="galleryphotosmall" src="[[+filename]]" alt="[[+filename]]" /></a></li>
I hesitate to recommend stuff because I haven’t yet succeeded in getting my first Modx site off the ground, but I have got a little gallery going (and I like the Pirobox JQuery lightbox, which is so easy to plug into the above).
Any good?
If you know how to give a new user permission to access the manager, do please post a reply in the same part of this forum.
All the best,
Michael