Expand my Community achievements bar.

Child node path in javascript

Avatar

Level 5

Hi,

I have images in dam in particular path.  like: content/dam/myproject/stateimage/image1.jpg....content/dam/myproject/stateimage/image2.jpg....

I am getting path through page property upto: content/dam/myproject/stateimage.

I am trying to iterate all the images path under this location(content/dam/myproject/stateimage.) in my component in javascript( serevr side script).Please suggest

 

 

Regards

6 Replies

Avatar

Level 10

If you want to use script to iterate through DAM Assets - much better to use JSP than JS. 

See" 

https://helpx.adobe.com/experience-manager/using/aem-dam-image-components.html

Why are you using JS to try and read JCR nodes? 

Avatar

Level 5

Hi

smacdonald2008 wrote...

If you want to use script to iterate through DAM Assets - much better to use JSP than JS. 

See" 

https://helpx.adobe.com/experience-manager/using/aem-dam-image-components.html

Why are you using JS to try and read JCR nodes? 

 

Hi Scott,

 

I am using slightly

My requirement is:  . I have one hero image component and : I am displaying different images on each page load and all the images present in dam.

I have asset folder name same as page name in dam.I am getting page path and trying to append the image in page path: like:

 page path :/content/myproject/mypage.html

dam path: /content/dam/myproject/mypage/myimage1.jpg,/content/dam/myproject/mypage/myimage2.jpg

trying to get the image path by server side script.

Regards,

Avatar

Level 5

All images stored in dam , at: dam path: /content/dam/myproject/mypage

images  dam path: /content/dam/myproject/mypage/myimage1.jpg,

                                     /content/dam/myproject/mypage/myimage2.jpg

 I need to iterate all images from this location  /content/dam/myproject/mypage to my component

 

 

Regards,

Avatar

Community Advisor

you should either have your JSP write the child assets in that folder as data attribute and you can use it then in your JS as needed.

OR

You can write a servlet to return all the child asset paths under your folder, make the Ajax call from JS to the servlet and use the response array as you want.

I will suggest you to take the servlet route, as with JSP once your page gets cached, then you won't be able to get the updated list of assets on any new addition of that asset under that dam folder.

~ Runal