Number of pictures in subgalleries (Gallery module)

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
pustofkj
Forum Members
Forum Members
Posts: 19
Joined: Fri Feb 04, 2011 1:57 pm

Number of pictures in subgalleries (Gallery module)

Post 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 :-)
Jos
Support Guru
Support Guru
Posts: 4019
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

Re: Number of pictures in subgalleries (Gallery module)

Post by Jos »

This is indeed not available. Maybe in a future release
farangprod
Forum Members
Forum Members
Posts: 15
Joined: Tue Nov 01, 2011 2:56 pm

Re: Number of pictures in subgalleries (Gallery module)

Post 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... ;)
Post Reply

Return to “Modules/Add-Ons”