Re: [xwiki-users] How to get top level page node in documentTree?
On Wed, Dec 21, 2016 at 5:37 PM, matmassawrote: > As you suggested I created a copy of the navigation panel to work on. > > My xwiki pages are structured as follows: > https://url/xwiki/bin/view/Projects/FOO/ > https://url/xwiki/bin/view/Projects/FOO2/ > [...] > > Inside "Projects" there are several "main" pages for each project (FOO is > an > example of the main page of a project). > FOO page has a tree structure as you correctly wrote: > FOO.A.WebHome > FOO.A.B.WebHome > FOO.X.Y.Z.WebHome > > I thought there were be something similar to manage the new pages logic (an > easier way to navigate nested pages). > Your suggestion about creating a new document reference using document > reference works well, I "played" with substrings: > > #set ($index = $openTo.indexOf('xwiki:') +6) > #set ($index2 = $openTo.indexOf('.',16)) > #set ($subb = $openTo.substring($index,$index2)) > #set ($resultpage= $subb.concat('.WebHome')) > > > Is there a better way to gain this result? > Yes. $services.model.resolveDocument('', 'default', $ doc.documentReference.spaceReferences.get(1)) assuming there are always at least 2 level of space references ("Projects" and the project itself), but you can do some checks to be safe. Hope this helps, Marius > > Thank you again, > -Matteo > > > > > > > -- > View this message in context: http://xwiki.475771.n2.nabble. > com/How-to-get-top-level-page-node-in-documentTree-tp7602158p7602176.html > Sent from the XWiki- Users mailing list archive at Nabble.com. >
Re: [xwiki-users] How to get top level page node in documentTree?
As you suggested I created a copy of the navigation panel to work on. My xwiki pages are structured as follows: https://url/xwiki/bin/view/Projects/FOO/ https://url/xwiki/bin/view/Projects/FOO2/ [...] Inside "Projects" there are several "main" pages for each project (FOO is an example of the main page of a project). FOO page has a tree structure as you correctly wrote: FOO.A.WebHome FOO.A.B.WebHome FOO.X.Y.Z.WebHome I thought there were be something similar to manage the new pages logic (an easier way to navigate nested pages). Your suggestion about creating a new document reference using document reference works well, I "played" with substrings: #set ($index = $openTo.indexOf('xwiki:') +6) #set ($index2 = $openTo.indexOf('.',16)) #set ($subb = $openTo.substring($index,$index2)) #set ($resultpage= $subb.concat('.WebHome')) Is there a better way to gain this result? Thank you again, -Matteo -- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-get-top-level-page-node-in-documentTree-tp7602158p7602176.html Sent from the XWiki- Users mailing list archive at Nabble.com.
Re: [xwiki-users] How to get top level page node in documentTree?
On Tue, Dec 20, 2016 at 3:47 PM, matmassawrote: > Hi, > > > I modified the Navigation panel menu in order to have a structured tree > menu > I would rather create a new panel, because otherwise you may have to resolve merge conflicts when upgrading XWiki (if the default Navigation panel changes in any way). > that always shows FOO page root and the opened path to reach the current > node (FOO project has nested pages). > > {{velocity}} > #panelheader("FOO MENU") > ## Escape special characters in macro parameter values. > #set ($openTo = $services.model.serialize($doc.documentReference, > 'default').replaceAll('([~"])', '~$1')) > {{documentTree showTranslations="false" showAttachments="false" > compact="true" showRoot="true" openTo="document:$openTo" > root="document:xwiki:FOO.WebHome" /}} > #panelfooter() > {{/velocity}} > > > Considering all my projects are inside Main\projects page, is there a way > to > This part "inside Main\projects page" is not clear. Can you give an example of a project reference / URL? > find dinamically the toplevel page node without having to specify the root > page name (FOO.WebHome)? > All pages that are nested inside FOO have "FOO" as part of their reference: FOO.A.WebHome FOO.A.B.WebHome FOO.X.Y.Z.WebHome You have the reference of the current document, $doc.documentReference. I guess you need to find the top level parent of the current document. You need to use the entity reference API in this case. See http://extensions.xwiki.org/xwiki/bin/view/Extension/Model+Module Hope this helps, Marius > > Thanks for reply > -Matteo > > > > > > > > -- > View this message in context: http://xwiki.475771.n2.nabble. > com/How-to-get-top-level-page-node-in-documentTree-tp7602158.html > Sent from the XWiki- Users mailing list archive at Nabble.com. >
[xwiki-users] How to get top level page node in documentTree?
Hi, I modified the Navigation panel menu in order to have a structured tree menu that always shows FOO page root and the opened path to reach the current node (FOO project has nested pages). {{velocity}} #panelheader("FOO MENU") ## Escape special characters in macro parameter values. #set ($openTo = $services.model.serialize($doc.documentReference, 'default').replaceAll('([~"])', '~$1')) {{documentTree showTranslations="false" showAttachments="false" compact="true" showRoot="true" openTo="document:$openTo" root="document:xwiki:FOO.WebHome" /}} #panelfooter() {{/velocity}} Considering all my projects are inside Main\projects page, is there a way to find dinamically the toplevel page node without having to specify the root page name (FOO.WebHome)? Thanks for reply -Matteo -- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-get-top-level-page-node-in-documentTree-tp7602158.html Sent from the XWiki- Users mailing list archive at Nabble.com.