Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Is there a way to read out the site root page dynamically depending on the site the page is placed in?

Avatar

Level 3

Yes, you can easily access the website root with the help of Page object. You can directly call getAbsoluteParent method to access the root page at a level of your choice.

Code snippet for the component would look like:

Sightly HTML code snippet:

<div data-sly-use.contentJS="content.js">

    ${contentJS.parentPage.path}

    </div>

Content.js

use(function() {

    return {

      parentPage: currentPage.getAbsoluteParent(1)

     };

});

0 Replies