Simpel
1
Hi.
We are migrating a jsp wiki to xwiki with api. Creating article after article one by one.
Some pages should function as index pages. But we do have a problem. There are no childs returned.
Absolute minimized code
{{velocity}}
$doc.getChildren()
{{/velocity}}
returns only an empty array.
[]
But there are lots of children to see in navigation panel.
If I create a page and subpages inside wiki by myself this code snippet shows all first level children, what we want to achieve.
Any ideas what is happening there?
Regards, Simpel
Simpel
2
To give some more information: macros {{children/}} and {{documentTree/}} are working but don’t fit our requirements.
We started with this code but this give us children with more than the first level:
{{toc start="2"/}}
{{html clean="false"}}
<style>
#xwikicontent>p {
columns: 3 auto;
}
#xwikicontent>ul {
columns: 3 auto;
width: 100%;
}
</style>
{{/html}}
{{velocity}}
#set ($children = $services.query.xwql("where doc.space like '$doc.getSpace().%' order by upper(doc.title)").execute())
#set ($first = '')
#set ($alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜß")
$children.size() Einträge
#foreach ($childRef in $children)
#set ($child = $xwiki.getDocument($childRef))
#set ($title = $child.getTitle())
#set ($childFirst = $title.substring(0,1).toUpperCase())
#if ($alphabet.indexOf($childFirst) == -1)
#set ($childFirst = '#')
#end
#if ($first != $childFirst)
#set ($first = $childFirst)
----
== $first ==
#end
[[$title>>$childRef]]
#end
#if (false)
{{documents location="$doc.getSpace()." count="50" actions="false" columns="doc.title"/}}
#end
{{/velocity}}
This gives us an index page with beginning-letter-toc but not only the children first level.
So we tried:
#set ($children = $doc.getChildren())
But this is as written in the first post not working on the pages we migrated with the api.
We use this api call with put:
/wikis/{wikiName}/spaces/{spaceName}[/spaces/{nestedSpaceName}]*/pages/{pageName}[?prettyNames={true,false}&objects={true,false}&class={true,false}&attachments={true,false}&minorRevision={true,false}]
That’s now our solution:
{{toc start="2"/}}
{{html clean="false"}}
<style>
#xwikicontent>p {
columns: 3 auto;
}
#xwikicontent>ul {
columns: 3 auto;
width: 100%;
}
</style>
{{/html}}
{{velocity}}
#set ($children = $services.query.xwql("select space.reference from Space space where space.parent like '$doc.getSpace()' order by upper(space.reference)").execute())
#set ($first = '')
#set ($alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜß")
$children.size() Einträge
#foreach ($childRef in $children)
#set($childRef = $escapetool.xml($childRef))
#set ($child = $xwiki.getDocument($childRef))
#set ($title = $child.getPageReference().getName())
#set ($childFirst = $title.substring(0,1).toUpperCase())
#if ($alphabet.indexOf($childFirst) == -1)
#set ($childFirst = '#')
#end
#if ($first != $childFirst)
#set ($first = $childFirst)
----
== $first ==
#end
[[$title>>$childRef]]
#end
{{/velocity}}
We now look for all the spaces which parent is the current space we are inside.
There is only one little thing I wonder about.
#set ($title = $child.getPageReference().getName())
was previously
#set ($title = $child.getTitle())
But that is not working. (getName()
is marked as deprecated that’s why I care.) What is the reason that getTitle()
isn’t working here?