CMS Development

PeterKumospace
Member

Loop Through Files

SOLVE

I'm working on building a module that will automatically build a marquee showcasing a set of images. I want to make it so that the images are automatically pulled from a folder in the files section of our Kumospace account. The intention is that admins can add or remove images from the folder in order to update the list of images displayed by the module. Is there any way to do this? Other's who have worked on our site have used jquery to get specific images from the files, but I'm having trouble getting all images from an entire folder.

0 Upvotes
2 Accepted solutions
Mike_Eastwood
Solution
Key Advisor | Gold Partner
Key Advisor | Gold Partner

Loop Through Files

SOLVE

Hi Peter,

 

Unfortunately, I think you're going to have to loop ALL the files and check the folder name on each file.

 

– Mike

View solution in original post

0 Upvotes
albertsg
Solution
Guide

Loop Through Files

SOLVE

Hi @PeterKumospace.

I don't understand much what you are trying to achieve here, but if you have a set of images inside a folder and you want to use them in your modules, you could copy the link to the folder into your module as scr attribute of your images and play with the naming of the images and a loop.

 

For example, you could have the following code:

 

{% for x in range(0,5) %}
	<img src="https://yourdomain.com/path-to-folder/file-{{x}}.jpg"/>
{% endfor %}

 

And your images should have the following names:

 

file-0.jpg

file-1.jpg

file-2.jpg

file-3.jpg

file-4.jpg

file-5.jpg

 

If content editors want to change an image, they just need to replace them inside the folder and keep the same name (and file extension).

 

Hope this brings some light to your issue 😊



Did my answer help you? Mark it as a solution


Do you need help with your site? Book time with me:


Book time with Albert

You can also connect with me on LinkedIn



View solution in original post

0 Upvotes
4 Replies 4
albertsg
Solution
Guide

Loop Through Files

SOLVE

Hi @PeterKumospace.

I don't understand much what you are trying to achieve here, but if you have a set of images inside a folder and you want to use them in your modules, you could copy the link to the folder into your module as scr attribute of your images and play with the naming of the images and a loop.

 

For example, you could have the following code:

 

{% for x in range(0,5) %}
	<img src="https://yourdomain.com/path-to-folder/file-{{x}}.jpg"/>
{% endfor %}

 

And your images should have the following names:

 

file-0.jpg

file-1.jpg

file-2.jpg

file-3.jpg

file-4.jpg

file-5.jpg

 

If content editors want to change an image, they just need to replace them inside the folder and keep the same name (and file extension).

 

Hope this brings some light to your issue 😊



Did my answer help you? Mark it as a solution


Do you need help with your site? Book time with me:


Book time with Albert

You can also connect with me on LinkedIn



0 Upvotes
PeterKumospace
Member

Loop Through Files

SOLVE

Hey, thanks for the suggestion. We have something similar in place in one spot, but we were hoping to manage to make it more dynamic. Looks like that isn't possible at this time though.

0 Upvotes
Mike_Eastwood
Solution
Key Advisor | Gold Partner
Key Advisor | Gold Partner

Loop Through Files

SOLVE

Hi Peter,

 

Unfortunately, I think you're going to have to loop ALL the files and check the folder name on each file.

 

– Mike

0 Upvotes
PeterKumospace
Member

Loop Through Files

SOLVE

Good to know, thanks Mike!