I have a template provider which creates some nested pages like:
- Page Root
- Subpage 1
- Subpage 2
- …
I assumed that Subpage 1
would have a parent reference to Template Root
. However, Subpage 1
's parent reference is a reference to the Template Root
(The Template of Page Root)
This is the code I’m working with:
def docSource = xcontext.method.input.get(1)
def ycontext = xcontext.method.input.get(2)
def document = ycontext.getWiki().getDocument(docSource, ycontext)
def parent = xwiki.getDocument(document.getParentReference())
System.out.println(document)
System.out.println(parent)
produces this output:
Entwicklung.Handbuch\.alpha1.Protokolle.2.WebHome // The actual pages
ReadingProtocol.Template.Startseite.WebHome // The template
How can I get from Subpage 1
to Page Root
when getParentReference()
does not actually point to it?
EDIT:
The code I posted is actually in an EventListener that listens to the DocumentCreatingEvent
. Maybe that’s the issue?