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

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
walter81
New Member
New Member
Posts: 5
Joined: Tue Oct 08, 2013 11:11 am

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

Post 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.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

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

Post 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.
walter81
New Member
New Member
Posts: 5
Joined: Tue Oct 08, 2013 11:11 am

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

Post 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.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

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

Post 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.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

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

Post by Rolf »

Huhh nice one. Will add it to the Gallery Wiki page!

Done: http://wiki.cmsms.nl/index.php/Gallery
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
Locked

Return to “Modules/Add-Ons”