Unified API to get page path with jcr:content | Community
Skip to main content
Peter_Puzanovs
New Participant
Apr 4, 2018 11:24 AM UTC
Solved

Unified API to get page path with jcr:content

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
joerghoh
joerghohAccepted solution
Employee
Apr 4, 2018 7:23 PM UTC

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

2 replies

joerghoh
joerghohAccepted solution
Employee
Apr 4, 2018 7:23 PM UTC

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

Translate
smacdonald2008
Level 10
Apr 4, 2018 12:30 PM UTC

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

Translate