Get "jcr:uuid" for "hst:containeritemcomponent" from freemarker template

Hello everyone,
I hope that I this wasn’t already answered but I attempted to search for a similar topic before creating a new one.

What I am attempting to do is fetch information from a custom API and inject that information into the freemarker template for each containeritemcomponent on an ExperiencePage. I am able to fetch the information successfully but injecting the information into a specific HTML element is proving to be challenging because I cannot seem to find a UUID which is unique across each containeritemcomponent in a given layout. As an example the layout can contain multiple “carousel” container items and I need to get a UUID for each carousel so that the javascript running in the freemarker template can update the appropriate HTML element (with an id containing the UUID so that they are distinctly identifiable). Currently I am able to use a document attached to the carousel to get a UUID but we also have container items without attached documents… this is where I am running into problems. Any ideas or insights into how to get a UUID for each container item would be greatly appreciated :slightly_smiling_face:.

You won’t have access to a container item as such. The container item does have java component that provides the data for the template. You could add an id in the configuration of that item and have the java component put that id on the request which the template can then add as a property to the html (use the id/name/class or any other way). Or have the java component generate an id according to some logic you control.

That did the trick, thank you!