Expand my Community achievements bar.

SOLVED

Unified API to get page path with jcr:content

Avatar

Community Advisor

Hi,

When using AEM API's sometimes pages are returned from methods come with jcr:content and sometimes without jcr:content.

Checking for jcr:content and then concat it, does not feel right.

Is there an API in AEM/Sling to do this for us?


Regards,

Peter

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

That behavior does very likely happen only when you use JCR query.  But it's very easy to cope with that:

resource r = ...

Page p  = r.adaptTo(Page.class)

and voila, it's normalized. But then try to avoid working on the page path (via p.getPath()) via String operations.

Jörg

View solution in original post

2 Replies

Avatar

Level 10

When working with Pages - for example - are you using PageManager API?

Avatar

Correct answer by
Employee Advisor

That behavior does very likely happen only when you use JCR query.  But it's very easy to cope with that:

resource r = ...

Page p  = r.adaptTo(Page.class)

and voila, it's normalized. But then try to avoid working on the page path (via p.getPath()) via String operations.

Jörg