Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Multifield with path of the page access page property

Avatar

Level 3

Hi Team,

                 I have requirement  to add page path in multifield and using that page path to access the page properties in sightly.

anyone worked on such type of requirement.

 

1 Accepted Solution

Avatar

Correct answer by
Level 6

Hi @savi50 

 

 

You can write a sling model for this. Read the page path from the multifield into the sling model. Once you have the page path get it as a resource then adapt it to a Page object. With getProperties() method you can fetch the properties from a Page object.

Below piece of code might help you to get started.

Resource resource = resourceResolver.getResource(<PAGE_PATH_FROM_MULTIFIELD>;
Page page = resource.adaptTo(Page.class);
ValueMap pageProperties = page.getProperties();

  Thanks,

View solution in original post

1 Reply

Avatar

Correct answer by
Level 6

Hi @savi50 

 

 

You can write a sling model for this. Read the page path from the multifield into the sling model. Once you have the page path get it as a resource then adapt it to a Page object. With getProperties() method you can fetch the properties from a Page object.

Below piece of code might help you to get started.

Resource resource = resourceResolver.getResource(<PAGE_PATH_FROM_MULTIFIELD>;
Page page = resource.adaptTo(Page.class);
ValueMap pageProperties = page.getProperties();

  Thanks,