Page 1 of 1

Number of pictures in subgalleries (Gallery module)

Posted: Thu Apr 21, 2011 7:47 am
by pustofkj
Hi all, I'd like to go through subgalleries of gallery and I'd like to get number of images in every subgallery. Is there any simple way to do? Here is my template code:

Code: Select all

<div class="gallery">
  <ul>
    {foreach from=$images item=subgallery}
      <li>
        <a href="{$subgallery->file}" title="{$subgallery->titlename}">
          {$subgallery->titlename} (NUMBER_OF_IMAGES_IN_SUBGALLERY?)
        </a>
      </li>
    {/foreach}
  </ul>
</div>
I know, here is variable $numimages, but it's not available inside the loop. How to make it available?
Thank you :-)

Re: Number of pictures in subgalleries (Gallery module)

Posted: Thu Apr 21, 2011 10:02 am
by Jos
This is indeed not available. Maybe in a future release

Re: Number of pictures in subgalleries (Gallery module)

Posted: Sat Mar 17, 2012 2:22 am
by farangprod
I come a little bit late but i was searching how to do about the same thing and i find a way!
I would like to know how many folder there is in each gallery
in my template, inside the loop, i call the gallery with special template:

Code: Select all

{Gallery dir=$image->filename template="nb_sub"}
so, all the loop code is:

Code: Select all

{foreach from=$images item=image}

     <div class="img">
	{if $image->isdir}
	   <a href="{$image->file|escape:'url'|replace:'%2F':'/'}" 
               title="{$image->titlename}">
           {CGSmartImage src=$image->thumb filter_resizetofit="500,200,transparent,1"
               alt=$image->titlename}
           </a>
	{/if}
     </div>

     <div class="legende">
          <h3>{$image->titlename}</h3>
          {$image->comment}
          {Gallery dir=$image->filename template="nb_sub"}
      </div>
{/foreach}
you can see that i use CGSmartImage to generate my thumbs but this not important in this case!

in the nb_sub template i just put this (french words):

Code: Select all

{if $numdirs >1}

   {$numdirs} galeries

{else}

   {$numdirs} galerie

{/if}
for the numbers of pictures in a subgallery i used in my template:

Code: Select all

{Gallery dir=$gallerydir|cat:"/"|cat:$image->filename template="nb_images"}
and for the nb_images template i just put:

Code: Select all

{$imagecount}
As i said before i come a little bit late but this solution can maybe help some others... ;)