CMS Development

PeterKumospace
Membre

Loop Through Files

Résolue

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 Votes
2 Solutions acceptées
Mike_Eastwood
Solution
Conseiller clé | Partenaire solutions Gold
Conseiller clé | Partenaire solutions Gold

Loop Through Files

Résolue

Hi Peter,

 

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

 

– Mike

Voir la solution dans l'envoi d'origine

0 Votes
albertsg
Solution
Guide

Loop Through Files

Résolue

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

You also connect with me on LinkedIn or Twitter

Voir la solution dans l'envoi d'origine

0 Votes
4 Réponses
albertsg
Solution
Guide

Loop Through Files

Résolue

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

You also connect with me on LinkedIn or Twitter

0 Votes
PeterKumospace
Membre

Loop Through Files

Résolue

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 Votes
Mike_Eastwood
Solution
Conseiller clé | Partenaire solutions Gold
Conseiller clé | Partenaire solutions Gold

Loop Through Files

Résolue

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 Votes
PeterKumospace
Membre

Loop Through Files

Résolue

Good to know, thanks Mike!