<a href="img/1_big.jpg" rel="lightbox[plants]" data-thumb="thumbs/1.png"><img src="img/1.jpg"/></a> <a href="img/2_big.jpg" rel="lightbox[plants]" data-thumb="thumbs/2.png"><img src="img/2.jpg"/></a> ...
но ничего другого пока в голову не лезет.
<?php
//define the path as relative
$path = "wedding";
$webpath ="foto/";
//using the opendir function
$dir_handle = @opendir($path) or die("Unable to open $path");
list_dir($dir_handle,$path);
function list_dir($dir_handle,$path)
{
// print_r ($dir_handle);
//running the while loop
while (false !== ($file = readdir($dir_handle))) {
$dir =$path.'/'.$file;
if(is_dir($dir) && $file != '.' && $file !='..' && $file != "Thumb.db")
{
if (strpos($file, '.jpg',1) ) {
$handle = @opendir($dir) or die("undable to open file $file");
echo "<a href='$webpath/big_photo/$file' rel='lightbox[plants]' data-thumb='$webpath/thumbs/$file'><img src='$webpath.$file' /></a>";
list_dir($handle, $dir);
}
}elseif($file != '.' && $file !='..' && $file != "Thumb.db")
{
if (strpos($file, '.jpg',1) ) {
echo "<a href='$webpath/big_photo/$file' rel='lightbox[plants]' data-thumb='$webpath/thumbs/$file'><img src='$webpath.$file' /></a>";
}
}
}
//closing the directory
closedir($dir_handle);
}
?>
[[fotogallery? &path=`wedding` &webpath=`foto` ]]
$path = "wedding";
$webpath ="foto/";
//using the opendir function
$dir_handle = @opendir($path) or die("Unable to open $path");<a href='$webpath/big_photo/$file...
$webpath = 'foto/wedding'; $path = $modx->config['base_path'].$webpath; //
wikibooks(ru) Ditto(en) | Wayfinder e-book | Заметки и о MODx
<?php
//define the path as relative
$webpath = 'foto/wedding';
$path = $modx->config['base_path'].$webpath;
//using the opendir function
$dir_handle = @opendir($path) or die("Unable to open $path");
list_dir($dir_handle,$path);
function list_dir($dir_handle,$path)
{
// print_r ($dir_handle);
//running the while loop
while (false !== ($file = readdir($dir_handle))) {
$dir =$path.'/'.$file;
if(is_dir($dir) && $file != '.' && $file !='..' && $file != "Thumb.db")
{
if (strpos($file, '.jpg',1) ) {
$handle = @opendir($dir) or die("undable to open file $file");
echo "<a href='$webpath/big_photo/$file' rel='lightbox[plants]' data-thumb='$webpath/thumbs/$file'><img src='$webpath.$file' /></a>";
list_dir($handle, $dir);
}
}elseif($file != '.' && $file !='..' && $file != "Thumb.db")
{
if (strpos($file, '.jpg',1) ) {
echo "<a href='$webpath/big_photo/$file' rel='lightbox[plants]' data-thumb='$webpath/thumbs/$file'><img src='$webpath.$file' /></a>";
}
}
}
//closing the directory
closedir($dir_handle);
}
?>
[[fotogallery? &webpath=`foto/wedding` ]]
<a href='/big_photo/IMG_3875.jpg' rel='lightbox[plants]' data-thumb='/thumbs/IMG_3875.jpg'><img src='.IMG_3875.jpg' /></a>


Логику сниппета, честно говоря, я не понял – зачем рекурсивно вызывается чтение каталога и как связаны $path и $webpath – непонятно.
В любом случае лучше использовать не относительные, а абсолютные пути, то есть не
"wedding"
а
$modx->config[’base_path’].’foto/wedding’
И чтобы внутри функции были видны переменные, надо их или передать в нее параметрами или объявить глобальными (это о $webpath).

Дальше сразу видно, что ничего хорошего не будет. Рекурсивный вызов сделан в оригинальном коде для вывода структуры каталога со всеми папками и файлами, а здесь пытаются папку вывести как файл…
А дальше - видно будет
Я выше писал
Вот только foto/wedding не подставилось
И чтобы внутри функции были видны переменные, надо их или передать в нее параметрами или объявить глобальными (это о $webpath).
// код чанка
$sTpl = $modx->getChunk('GalleryRowTpl');
// массив с плейсхолдерами
$aSearch = array('[+item.image.big+]', '[+item.image.min+]', '[+item.image.med+]');
// циклично обходим директорию
foreach (glob($modx->config['base_path']."thumbs/big/*.{jpeg,jpg,gif,png}", GLOB_BRACE) as $sTmp) {
// определяем имя файла
$sFilename = basename($sTmp);
// проверяем наличие тумбы и копии среднего размера
if (is_file($modx->config['base_path'].'thumbs/med/'.$sFilename) and is_file($modx->config['base_path'].'thumbs/min/'.$sFilename)) {
// массив замен
$aReplace = array('[(base_url)]thumbs/big/'.$sFilename, '[(base_url)]thumbs/min/'.$sFilename, '[(base_url)]thumbs/med/'.$sFilename);
// вывод изображения
$aRow[] = str_replace($aSearch, $aReplace, $sTpl);
}
}
// выводим все изображения
if (is_array($aRow)) {
return implode("\n", $aRow);
}
<a href="[+item.image.big+]" rel="lightbox[plants]" data-thumb="[+item.image.min+]"><img src="[+item.image.med+]" /></a>
// папка с фото
if(!$folder) return;
// код чанка
$sTpl = $modx->getChunk('GalleryRowTpl');
// массив с плейсхолдерами
$aSearch = array('[+item.image.big+]', '[+item.image.min+]', '[+item.image.med+]');
// циклично обходим директорию
foreach (glob($modx->config['base_path']."foto/".$folder."/big/*.{jpeg,jpg,gif,png}", GLOB_BRACE) as $sTmp) {
// определяем имя файла
$sFilename = basename($sTmp);
// проверяем наличие тумбы и копии среднего размера
if (is_file($modx->config['base_path'].'foto/'.$folder.'/med/'.$sFilename) and is_file($modx->config['base_path'].'foto/'.$folder.'/min/'.$sFilename)) {
// массив замен
$aReplace = array('[(base_url)]'.'foto/'.$folder.'/big/'.$sFilename, '[(base_url)]'.'foto/'.$folder.'/min/'.$sFilename, '[(base_url)]'.'foto/'.$folder.'/med/'.$sFilename);
// вывод изображения
$aRow[] = str_replace($aSearch, $aReplace, $sTpl);
}
}
// выводим все изображения
if (is_array($aRow)) {
return implode("\n", $aRow);
}
[[GalleryOutput? &folder=`wedding`]]
