Page 1 of 1
How can I loop through sub folders in gallery module.
Posted: Tue Mar 25, 2014 8:48 pm
by lazut
I am trying to loop through images in gallery module to pick images whose image field value is bathroom using this folowing code but it's not loop through sub folders in gallery module only brings images which are in the gallery main folder
Code: Select all
{foreach from=$images item="image"}
{if $image->fields.used_in.value =="Bathroom"}
{/if}
{/foreach}
How can I loop through sub folders in gallery module.
Re: How can I loop through sub folders in gallery module.
Posted: Wed Mar 26, 2014 12:37 am
by JohnnyB
I think you have to choose which gallery folders to use in the {Gallery} tag or show all folders.
Re: How can I loop through sub folders in gallery module.
Posted: Wed Mar 26, 2014 8:39 am
by velden
From the help:
(optional) action="default" - Override the default action. Use it in combination with the above parameters. Possible values are:
'showrandom' - to display a set of random thumb-images (applies only to the images which are stored in the database, defaults to a number of 6 images). Use '/*' after the directoryname in the dir parameter to include images from subdirectories
'showlatest' - to display the most recently added images (applies only to the images which are stored in the database, defaults to a number of 6 images) The dir parameter can be set, or the default Gallery-root will be used. Subdirectories are automatically included
'showlatestdir' - to display a set of random thumb-images from the most recently added directory (applies only to the images which are stored in the database, defaults to a number of 6 images)
'gallerytree' - to display links to all galleries and subgalleries. This uses the gallerytree template by default, but this can be changed with the template parameter. Use the dir parameter to display a subset of the gallerytree. (applies only to the galleries which are stored in the database)
Note that images are only stored in the database when the specific gallery is visited in the admin or frontend.
Not sure if it then contains links to the images itself too.
If not, you have to recurse which is actually possible from within template.
Re: How can I loop through sub folders in gallery module.
Posted: Wed Mar 26, 2014 8:54 pm
by Rolf
Re: How can I loop through sub folders in gallery module.
Posted: Thu Mar 27, 2014 9:03 am
by lazut
Thanks for all replying my post. I should have explained it in better way so my difficulty is this;
I have created a main folder as named Projects and sub folders for each different projects under "Projects" folder.
I'd like to use
http://www.twospy.com/galleriffic/ this gallery plugin instead of default templates and I have created a template .It is working only if I use it for one specific folder like this
Code: Select all
{Gallery dir="Projects/Project X" template="Galleriffic"}
but for
Code: Select all
{Gallery dir="Projects" template="Galleriffic"}
this template that I have created shows sub folders but when I click the sub folder links they are not working, I think there is no code in the plugin to handle links of sub folders and I couldn't change original code because I don't have any knowledge other than some very basics.
so I thought may be I can find a way to loop through these folders in gallery module. I have to use sub folders otherwise it would get very long and would not be practical
I really liked this plugin so I am trying find out a way to solve it,
appreciate your help
Re: How can I loop through sub folders in gallery module.
Posted: Thu Mar 27, 2014 9:15 am
by velden
I think there is no code in the plugin to handle links of sub folders and I couldn't change original code because I don't have any knowledge other than some very basics.
That makes no sense I think. A link to sub folder implies a reload of the page with the sub gallery.
I once build a site with Gallerific, but it just has two albums which I think I hard coded in a link:
https://tinyurl.com/pl5tuff
Post a link to your gallery so we can think harder/better

Re: How can I loop through sub folders in gallery module.
Posted: Thu Mar 27, 2014 2:09 pm
by JohnnyB
This may be a stupid guess on my part, but I'll try stupid things and for some reason they work...
Change
{Gallery dir="Projects" template="Galleriffic"}
to
{Gallery dir="Projects/" template="Galleriffic"}
I remember having to use the trailing slash the last time I referenced the top directory a couple years ago. It might not work though, so don't hold your breath

Re: How can I loop through sub folders in gallery module.
Posted: Sat Mar 29, 2014 3:18 am
by lazut
I have used this
Code: Select all
{Gallery dir='Projects/' template="Galleriffic"}
for this page
http://www.qdistone.com/test-3/test-gal ... m-gallery/ sub folder links are not working and you will also see images in the 'Projects' folder is working
and I have used
Code: Select all
{Gallery dir='Kitchen/English-Walnut' template="Galleriffic"}
for this page
http://www.qdistone.com/test-3/test-gal ... gallery-2/ which has no sub folder it is working..
I guess I have to create different pages for each projects and give link to them under main project page.
Re: How can I loop through sub folders in gallery module.
Posted: Sat Mar 29, 2014 8:39 am
by velden
- The template as you use it indeed has no support for sub folders.
- What do you want?
Allow sub-folders in the list of photos?
OR Loop through all images and show images that have 'bathroom' in their image field?
- very important:
validate your html output. It's a total mess. A miracle that browsers do display images at all

Re: How can I loop through sub folders in gallery module.
Posted: Sun Mar 30, 2014 12:50 am
by lazut
I had some progress change the template which I have created like this
Code: Select all
<div class="navigation col-md-4" id="thumbs" >
<ul class="thumbs noscript">
{foreach from=$images item="image"}
{if $image->isdir}
<a class="thumb " name="{$image->title}" href="{$image->file}" title="{$image->titlename}"><img src="{$image->thumb|escape:'url'|replace:'%2F':'/'}" alt="{$image->titlename}" /></a><br />
{$image->titlename}
{else}
<li>
<a class="thumb img-responsive" name="{$image->title}" href="{$image->file}" title="{$image->title}" ><img src="{$image->thumb|escape:'url'|replace:'%2F':'/' }" alt="{$image->titlename}" class="img-thumbnail" /></a>
<div class="col-md-9 col-md-offset-1 caption">
<h1 class="text-info">{$image->fields.name.value} </h1> </div>
</li>{/if}
{/foreach}
</ul>
</div>
now links works I can click them go to sub folder but sub folders are now empty ..I think I am lost here

Let's start over again , I can definitely say I want to put my all images under the Project folder and create sub folders for different projects and loop through all images and show images that have 'bathroom' in their image field as you have said or let's say show images that have "living room" in their image field.
so need more home work
Re: How can I loop through sub folders in gallery module.
Posted: Sun Apr 06, 2014 8:59 pm
by kneep
I also want to know if it is possible to show all galleries with their images on 1 page. I want to use this for a new one page website i'm building.
So it looks like this:
Gallery 1:
Image 1 / Image 2 / Image 3 / Image 4 / Image 5 / etc...
Gallery 2:
Image 1 / Image 2 / Image 3 / Image 4 / Image 5 / etc...
Gallery 3:
Image 1 / Image 2 / Image 3 / Image 4 / Image 5 / etc...
Gallery 4:
Image 1 / Image 2 / Image 3 / Image 4 / Image 5 / etc...
Anyone who has made this possible with Gallery module?
Re: How can I loop through sub folders in gallery module.
Posted: Mon Apr 07, 2014 7:29 am
by velden
@Kneep:
http://forum.cmsmadesimple.org/viewtopi ... 33#p290133
Describes a way to do it. Note that that post has a hardcoded path in template 'projecten' and I used it to display only first image of each Gallery, others are hidden by css. (I now realize it was an inefficient implementation because loading thumbnails to hide them makes no sense. But for your case it will work, just don't hide with css).