Getting values of other components in aem

763 Views Asked by At

I have created 2 components (component A, component B) and 2 pages(page A,page B) in AEM 6.4. I have added component A to page A and component B to page B. My requirement is to display the value authored in page A to page B. How can I achieve this. Thanks in advance

1

There are 1 best solutions below

0
On

If your structure is fixed then you could just use data-sly-resource to include the component B node from Page B to page A.

Assuming:

/content/mysite/pageA/jcr:content/root/container/componentA
/content/mysite/pageB/jcr:content/root/footer/componentB

You could do (in componentA's HTL script):

<sly data-sly-resource="/content/mysite/pageB/jcr:content/root/footer/componentB"></sly>

However, if you want to share editable content between multiple pages, your should really use Experience Fragments. They're reusable editable component blocks and the Core Components Experience Fragment component also allows using the same localization as you current page (especially useful when using the Experience Fragment in the header/footer of your page template). See also the WKND tutorial examples!