On 01/30/2011 10:07 PM, Eugen Colesnicov wrote:
I am trying to use getTOC, but unfortunately, my example always returns zero
The getTOC method works only for the xwiki/1.0 syntax. For syntax xwiki/2.0 there's no equivalent API method. You could get hold of the headings in the 2.0 syntax using programming rights to access $doc.getDocument().getXDOM() and then walk through the DOM looking for headings. But this is a bit too complicated. Why exactly do you need the TOC? Can't you just use the {{toc}} macro?
...
{{velocity}} #set($d=$xwiki.getDocument('Sandbox.WebHome')) #set($tree=$d.getTOC(0,3,false)) $tree.size() #foreach($key in $tree.entrySet()) * $key.value.text #end {{/velocity}}
Can somebody help me with syntax? What's I doing wrong?
Thanks beforehand! Eugen Colesnicov
-- Sergiu Dumitriu http://purl.org/net/sergiu/