Page 1 of 1

Gallery: Number of items (images/folders) in subfolder

Posted: Tue Oct 08, 2013 11:18 am
by walter81
Hello,

With the Gallery module it is possible to show the number of items (images, folders) in the current folder.
Does anybody know if it is possible to show the number of items in the subfolder?
There is no variable such like $image->itemcount or something.

The variable only exists for the current directory.

I'd like to display in my gallery overview how many images each subfolder contains.

Re: Gallery: Number of items (images/folders) in subfolder

Posted: Wed Oct 09, 2013 7:30 am
by velden
It is possible to call {Gallery} from within a gallery template so that could be a (maybe inefficient) way to call Gallery for the subfolder and only display/assign the image count.

I have a short, incomplete example on how to do that (other use). I couldn't get it to work when using a template parameter so I made the template default TO BE CALLED FOR COUNT the default template.

Save this template (e.g. 'foo') and DO NOT make it default.

Code: Select all

{assign var="org_gallerydir" value=$gallerydir}

{foreach from=$images item=image name=img}
{if $image->isdir}   or something like that
  {Gallery dir="$org_gallerydir/`$image->filename`"}
{else}
... do your normal layout for images...
{/if}
{/foreach}
Then create a gallery template that only outputs the the html you want to display for a subfolder item and make that the DEFAULT template.

From within your page (template) you call {Gallery template="foo"}

<offtopic>
I use a similar approach when I have a Gallery that only has subgalleries. From each subgallery I only display the first thumb and all subsequent image-LINKS are hidden, though available.

Like a portfolio for different projects that are available on one page.
Example: http://tinyurl.com/pjo77cq#projecten (go to projecten).
Every project is a subgallery. Only the first thumb of every subgallery is displayed, together with gallery title/comment. 'Behind' each thumb are the links to the other subgallery-images so the fancybox thing can do its job.

It has an extra feature to go to next/previous project from within fancybox popup. That, combined with the filter and shuffle feature, was a nice puzzle to create.

Re: Gallery: Number of items (images/folders) in subfolder

Posted: Wed Oct 09, 2013 5:51 pm
by walter81
Thank you very much for this workaround.
It was quite easy to do it this way.

In my default template I inserted this two lines

Code: Select all

{assign var="org_gallerydir" value=$gallerydir}
...
{foreach from=$images item=image}
  {if $image->isdir}
...
{Gallery dir="$org_gallerydir/`$image->filename`" template="aantalfotos"} foto's

  {else}
...
{/foreach}
...
The template code of the template named 'aantalfotos' is

Code: Select all

{$numimages}
The idea you told me you used on your own website, is very nice!
I am working on an other website, where I will try to do the same trick.

Re: Gallery: Number of items (images/folders) in subfolder

Posted: Wed Oct 09, 2013 8:23 pm
by velden
Good it works!
walter81 wrote: The idea you told me you used on your own website, is very nice!
I am working on an other website, where I will try to do the same trick.
It is not my own website. However I implemented cmsms and did some customization so the fancybox things works like it does now.

Re: Gallery: Number of items (images/folders) in subfolder

Posted: Wed Oct 09, 2013 8:42 pm
by Rolf
Huhh nice one. Will add it to the Gallery Wiki page!

Done: http://wiki.cmsms.nl/index.php/Gallery