How can I loop through sub folders in gallery module.

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
lazut
Forum Members
Forum Members
Posts: 15
Joined: Thu Dec 22, 2011 3:54 pm

How can I loop through sub folders in gallery module.

Post 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.
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm

Re: How can I loop through sub folders in gallery module.

Post by JohnnyB »

I think you have to choose which gallery folders to use in the {Gallery} tag or show all folders.
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: How can I loop through sub folders in gallery module.

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

Re: How can I loop through sub folders in gallery module.

Post by Rolf »

- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
lazut
Forum Members
Forum Members
Posts: 15
Joined: Thu Dec 22, 2011 3:54 pm

Re: How can I loop through sub folders in gallery module.

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

Re: How can I loop through sub folders in gallery module.

Post 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 :)
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm

Re: How can I loop through sub folders in gallery module.

Post 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 8)
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
lazut
Forum Members
Forum Members
Posts: 15
Joined: Thu Dec 22, 2011 3:54 pm

Re: How can I loop through sub folders in gallery module.

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

Re: How can I loop through sub folders in gallery module.

Post 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 :D
lazut
Forum Members
Forum Members
Posts: 15
Joined: Thu Dec 22, 2011 3:54 pm

Re: How can I loop through sub folders in gallery module.

Post 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 Image
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
kneep
Forum Members
Forum Members
Posts: 20
Joined: Mon Jul 28, 2008 7:45 am

Re: How can I loop through sub folders in gallery module.

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

Re: How can I loop through sub folders in gallery module.

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

Return to “The Lounge”