Page manager return null for mapped page with Sling Mapping

Avatar

Avatar

UladzislauMinic

Avatar

UladzislauMinic

UladzislauMinic

14-03-2019

Hi All,

I am using Sling Mapping (configurations are located under /etc/map) for mapping the resources , e.g. /content/path/en should get page /content/path_real/en.

When I try to get resource via resourceResolver.getResource("/content/path/en") it works correctly and return the resource under path /content/path_real/en.

But when I try to get page via pageManger.getPage(""/content/path/en") it returns null.

Is there any way to configure pageManager so they also use sling mapping configuration from /etc/map folder?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

891

Correct Answer

1.0K

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

891

Correct Answer

1.0K
Jörg_Hoh
Employee

14-03-2019

The pagemanager does accept only repository paths, but not request paths (which can be mapped to resource paths).

Jörg

Answers (2)

Answers (2)

Avatar

Avatar

Gaurav-Behl

MVP

Total Posts

1.1K

Likes

226

Correct Answer

281

Avatar

Gaurav-Behl

MVP

Total Posts

1.1K

Likes

226

Correct Answer

281
Gaurav-Behl
MVP

14-03-2019

As Jörg mentioned above,  get the resource first using resourceResolver.getResource("/content/path/en")

then use pageManger.getPage(resource.getPath())

Avatar

Avatar

Prince_Shivhare

Avatar

Prince_Shivhare

Prince_Shivhare

14-03-2019

If the resource at that path does not exist or is not adaptable to Page, null is returned.

are you doing like this?

PageManager pageManager = resolver.adaptTo(PageManager.class);

  if (pageManager != null) {

  Page page = pageManager.getPage(path);

or something like --

PageManager pageManager = resource.getResourceResolver().adaptTo(PageManager.class);

Page rootPage = pageManager.getPage(pagePath);

~ Prince