[xwiki-users] Using getTOC function
I am trying to use getTOC, but unfortunately, my example always returns zero ... {{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 -- View this message in context: http://xwiki.475771.n2.nabble.com/Using-getTOC-function-tp5975427p5975427.ht... Sent from the XWiki- Users mailing list archive at Nabble.com.
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/
Thanks Sergiu! My task: I get external data using SQLPlugin. Information from some fields I using as s structure levels. I need - to create panel with these structure levels. This panel should have additional functionality as a toc macro: a) levels should be with minuses & pluses, b) levels should collapse and reverse by clicking on pluses and minuses. I can construct these tree on a panel as a separete SQL select from external data (as a result I will have 2 selects), but my idea was - that I will select data from external source only on page and tree on a panel will create automaticaly using getTOC ... Ok, if use getTOC is not possible in xwiki syntax 2.0 - I will make separate SQL select for my panel with custom tree. -- Best regards Eugen Colesnicov -- View this message in context: http://xwiki.475771.n2.nabble.com/Using-getTOC-function-tp5975427p5976305.ht... Sent from the XWiki- Users mailing list archive at Nabble.com.
participants (2)
-
Eugen Colesnicov -
Sergiu Dumitriu