Page 1 of 1

[semi-solved]Gallery: number of images in folders

Posted: Tue Jan 25, 2011 11:43 pm
by konsument
Hi together,

is there a way to get the number of images of albums in a subfolder?

Theres allready a feature request postet some time ago: http://dev.cmsmadesimple.org/feature_request/view/5400

Anybody an idea how to solve this problem?

Re: Gallery: number of images in folders

Posted: Wed Jan 26, 2011 2:52 am
by Jos
The page where you edit a Gallery-template contains an icon which shows you all the template variables you can use with Gallery. You can find it right underneath the first template field.

The same list with variables is also available in the Gallery documentation: http://wiki.cmsmadesimple.org/index.php ... _variables

At this time the number of images is only available in the subgallery itself.

Re: Gallery: number of images in folders

Posted: Wed Jan 26, 2011 2:09 pm
by konsument
ok thanks for the info.

Anyway, Ive build my own quick and dirty udt to solve this problem:

Code: Select all

global $gCms;
$dir = $gCms->config['root_path'] . DIRECTORY_SEPARATOR .'uploads/images/Gallery/';
$albumdir = $params['gallerydir'];

$d = opendir($dir . $albumdir);
$count = 0;

while(($f = readdir($d)) !== false)
if(ereg('.jpg$', $f))
++$count;
closedir($d);

$finalamount = $count/2;

echo "$finalamount";
The call in the Gallery template is:

Code: Select all

{foreach from=$images item=image}
{if $image->isdir}
{tagname gallerydir=$image->filename} images
{/if}
{/foreach}
This works fine for me, because Ive only one level galleries

Im no programmer at all - Im just happy to solve it for me with this :)