I have a Velocity script direct in a page from where I want to do some scripting and access other pages. The script is executing and the Document Object doc is not empty. All the other outputs are working. But only getContent is always empty.
Any ideas?
Hello, first you should not define a $doc variable since it’s already defined and a reserved name.
Then in your script you use a $page variable but it’s not defined.
IMO your reference is wrong but since you’re not showing what you’ve used, it’s hard to help you more. Just navigate to your page and click on the Information tab to get the page reference.
Sorry for the wrong post.
Thx for your quick reply.
I am a velocity and XWiki API beginner.
I have just posted a snipplet, the page variable is defined in a loop outside…
The doc variable is now renamed in xdoc, but that was not the reason.
It was indeed a wrong page reference!
The story is, the script is for a migration of pages to restore a page hierachy from another Wiki (TWiki). All pages are already imported in Xwiki and with the “Nested Pages Migration” converted from terminal pages to nested pages.
But the structure is flat at the moment.
In the migrated flat documents there is a meta data field somewhere in a comment which contains the old parent. The script should iterate over all flat documents, extract the ParentDocument out of the metadata and restore the hierarchy again.
`
Is there a good API-DOC.
I have already looked in the Code
At the moment I am struggling with setting a parent page. How is this done?
You just need to create your page using the right reference to be in a hierarchy, for example A.B.WebHome (using a document reference, or A.B using a page reference), means that the B page is under the A page.
the solution for me was, to set the parent pages in the old XWiki 7.3 version with Velocity and then transfer the Pages to current 15.10. LTS Version. In the current version use the “Nested Pages Migration” Extension. It has done the job to convert the terminal pages into nested pages and restore the whole deep hierarchy respecting the structure.