Srinivasarao_Ko
I'm new here

Selecting multiple images/folder at a time

Jump to solution

Hi,

I am working on image galleries(FS 5.0). At present we allowing editors to choose each pic individually. Now we are planning to give one option to editors that selecting multiple images at once or selecting folder itself which contains multiple images.

Firstly I have tried to implement of selecting multiple images at once, but failed. as I didn't see any support from FS API(Help) to select multiple images at a once. we are using FS_REFERENCE component to select the picture. this component is not allowing to select multiple images.

Later I tried to select the folder which contains multiple images. this is possible by giving allow option as folder(<ALLOW type="mediafolder"/>). but my template treating this folder itself an image and it is not going into the content of folder while displaying. my question here is how to get the content of folder while displaying images when allow type is "mediafolder".

any help would be appriciated.

Thanks in advance.

Srinivas.

1 Solution

Accepted Solutions
Srinivasarao_Ko
I'm new here

Hi,

Finally I have implemented this without writing any script and without using getChildren() method. below is the procedure that I have implemented.

1. firstly am checking the gallery item is folder or by using isFolder() method of StoreElement interface.

2. if yes, am getting the childcount of folder in a variable by calling getChildCount() method of StoreElement interface.then am iterating a for loop from 0(zero) to childcount(size).

3. in each loop, am checking the child type is Media or not. If it is Media then am checking it is picture or file.

If it is picture am continuing with my code.

Sample code:

$CMS_IF(GalleryItem.get(#global.language,"stPicture").get().get().isFolder())$

           $CMS_SET(varChildCnt, GalleryItem.get(#global.language,"stPicture").get().get().getChildCount())$

           $CMS_IF(varChildCnt > 0)$

               $CMS_FOR(childNum,[0 .. varChildCnt-1])$

                   $CMS_IF("Media".equals(GalleryItem.get(#global.language,"stPicture").get().get().getChild(childNum).getElementType())

                             && GalleryItem.get(#global.language,"stPicture").get().get().getChild(childNum).getType == 1)$  $-- Type 1 means image, 0 means file--$

    Continueing with my logic..........

Thanks,

Srinivas.

View solution in original post

0 Kudos
6 Replies
pavone
I'm new here

Hello,

every store element offers different getChildren methods. This should be what you're looking for.

See StoreElement for more information.

Best regards

Tim

Hello Srinivas,   

do you need further help or did Tim's reply already help you? If so, it would be great if you marked

his reply as "correct answer" so that other community users find the solution easily. If you have

already found a solution by yourself, it would be very kind of you, if you posted it here.   

Best regards 

Thorsten

0 Kudos

Hi,

Thanks Tim for your remarkable comments. Since I get into other prioritized tasks I didn't get the time to work on this issue. So, I have not replyed to you, sorry for that. now I have started working on this again. I too feeling that your suggention will workout here. I am working towards that. I will keep updating you.

Thanks again.

Regards,

Srinivas.

0 Kudos

Hi,

I have tried your approach Tim. since getChildren() is a method of store element, I have understood that I need to right one script file with some java stuff to achieve this. I thought it will be a lenghly process although we can do it in that way. I believe there should be a smarter way than writing a script file(with in HTML tab of Template). If you have something like that please post.

Thanks in advance.

Regards

Srinivas.

0 Kudos

Hello Srinivas,

if a script is more than a few lines it is possible to write a FirstSpirit module with an executable java class and reference it inside the script. For us that is the recommend way of doing this.

You can find further information about this here and here (German PDF about FirstSpirit module Developement).

Regards

Marian

0 Kudos
Srinivasarao_Ko
I'm new here

Hi,

Finally I have implemented this without writing any script and without using getChildren() method. below is the procedure that I have implemented.

1. firstly am checking the gallery item is folder or by using isFolder() method of StoreElement interface.

2. if yes, am getting the childcount of folder in a variable by calling getChildCount() method of StoreElement interface.then am iterating a for loop from 0(zero) to childcount(size).

3. in each loop, am checking the child type is Media or not. If it is Media then am checking it is picture or file.

If it is picture am continuing with my code.

Sample code:

$CMS_IF(GalleryItem.get(#global.language,"stPicture").get().get().isFolder())$

           $CMS_SET(varChildCnt, GalleryItem.get(#global.language,"stPicture").get().get().getChildCount())$

           $CMS_IF(varChildCnt > 0)$

               $CMS_FOR(childNum,[0 .. varChildCnt-1])$

                   $CMS_IF("Media".equals(GalleryItem.get(#global.language,"stPicture").get().get().getChild(childNum).getElementType())

                             && GalleryItem.get(#global.language,"stPicture").get().get().getChild(childNum).getType == 1)$  $-- Type 1 means image, 0 means file--$

    Continueing with my logic..........

Thanks,

Srinivas.

0 Kudos