Multifield with path of the page access page property | Community
Skip to main content
Level 2
March 1, 2022
Solved

Multifield with path of the page access page property

  • March 1, 2022
  • 1 reply
  • 881 views

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.

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by JeevanRaj

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,

1 reply

JeevanRaj
Community Advisor
JeevanRajCommunity AdvisorAccepted solution
Community Advisor
March 1, 2022

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,