문제

I'm building a custom panel for my Xwiki (Cloud hosted). I need to do a hierarchy tree on my panel, and for that, I need to know the parent of a space, so I can do an #if clause...

#set ($spaces = $xwiki.spaces)
#set ($hiddenSpaces = ["XWiki", "Admin", "Panels", "Blog", "Main"])
#foreach ($space in $spaces)

Here.. how can I achieve something like '$space.parent', that works on a doc????

Like I said I have tried with $space.parent, but this is not working.. it just prints it out on my screen...

Please, I'm stuck on this

EDIT: I think the objects returned by $xwiki.spaces are Strings... is there a way to get a space from the xwiki, something like $xwiki.getSpace($space).parent?

도움이 되었습니까?

해결책

There is no such thing as a the parent of a space yet, since XWiki only has documents represented in the database. However, by convention the space is usually represented by its homepage, SpaceName.WebHome. So, you should check the parent on this document.

#set ($spaces = $xwiki.spaces)
#set ($hiddenSpaces = ["XWiki", "Admin", "Panels", "Blog", "Main"])
#foreach ($space in $spaces)
  #set ($spaceHome = $xwiki.getDocument("${space}.WebHome"))
  #set ($spaceParent = $spaceHome.parent)
  ... and the rest of the code ...
#end

But this uses slightly deprecated methods. You should use entity references instead of strings:

  #set ($spaceHome = $xwiki.getDocument($services.model.createDocumentReference($doc.documentReference.wikiReference.name, $space, '', 'default')))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top