XWiki 9.11.3. We are generating a PDF export of a single page, with several dozen children. The child page tree is only one level deep. The root page has a documentTree which shows the children in alphabetical order based on folder name (identical to file name for each article) which is great. This forms a visual table of contents for the site.
When we generate a PDF Export of the root page, and include children, the pages in the PDF TOC come out in a random order, apparently by creation date. SOMETIMES they come out in alphabetical order as desired, but itās random.
Just a note, the only work-around Iāve been able to come up with is to create a new separate page with an {{include}} macro for each of the child pages in the correct order, which I can print out.
However, Itās a maintenance headache, and the page is extremely slow to load as it is including 51 pages and a lot of content.
Hi! No, there has been no progress, so we are continuing to generate our PDF āby handā, creating a separate page of links to get the results in the right order.
Warning: Iām new to XWiki, and in particular to scripting it - but I found a way to do what I want that seems to do what you want, using a script (I used Python because I know Python).
My situation:
Iām writing a novel in xWiki.
Using xWiki 11.6. I didnāt research backward compatibility.
I have a single āparentā page thatās not very meaningful (and it gets ignored in my script), and all the information I want to print is in child pages off of that.
The titles of the child pages are what I want to sort on; I start them with sequence numbers to make this obvious, e.g, ā0001 First page,ā ā0002 Page that will print second,ā etc.
My child pages are only one layer deep. Layers could be accommodated with a loop; I didnāt (yet).
What I want:
To print the whole novel, except:
There are some child pages I donāt want to print. I created my own convention: Their titles contain the phrase, āDO NOT PRINTā. (Position within the title doesnāt matter).
I want to print the page title as an H2, then the page contents, then a breaker line.
What I did:
Created a new and dedicated child page (called āEntire book DO NOT PRINTā).
Put the Python script below on that child page (clicked on āSourceā and pasted this).
Put a link to this child page on the parent page. When I want to export the whole story, I go to this child page and just export (PDF, RTF, whatever) that single page.
{{python}}
sql = "where doc.parent='"+doc.parent+"' and doc.title not like '%DO NOT PRINT%' order by doc.title"
for item in xwiki.searchDocuments(sql):
d = xwiki.getDocument(item)
print "==",d.title,"=="
print d.content
print "----"
{{/python}}
(The four lines after the āfor itemā¦ā line are indented two spaces. Pythonā¦)
Other characteristics you could print (other than ād.titleā and ād.contentā) would be I think those listed on this link in the docs. Replace āXWD_ā with ād.ā and add it to the loop.
One more, and then Iāll stop posting on this. I had a āChildrenā macro on my home page for the book, but it shows a subset and then ā7 moreā at the bottom, which was inconvenient. Iāve now changed my home page to whatās below, and itās better.
Tim
{{python}}
print "Chapters:"
sql = "where doc.parent='"+doc.fullName+"' and doc.title not like '%DO NOT PRINT%' order by doc.title"
for item in xwiki.searchDocuments(sql):
d = xwiki.getDocument(item)
print "* [["+d.title+">>doc:"+item+"]]"
print ""
print "Other Material:"
sql = "where doc.parent='"+doc.fullName+"' and doc.title like '%DO NOT PRINT%' order by doc.title"
for item in xwiki.searchDocuments(sql):
d = xwiki.getDocument(item)
print "* [["+d.title+">>doc:"+item+"]]"
{{/python}}