[xwiki-users] Menu Application rendering content
Hello, I used the Menu Application [1] to define a horizontal menu, after page header, and it's very nice and very user-friendly. I wonder if it could (easily) be feasible, to have the content ("Menu Structure") of the menu rendered ? My point would be to put some velocity scripting in it, to achieve more dynamic menus (display parts depending on user rights, generate some lists of items, etc). A bit like the jsx/ssx extensions do. I had a look but I didn't find where the "magic" operates :) Thanks, Jeremie [1] http://extensions.xwiki.org/xwiki/bin/view/Extension/Menu+Application
Hi Jeremie, The "Menu Structure" is rendered! Take a look at http://extensions.xwiki.org/xwiki/bin/view/Extension/Menu+Application#HExamp... . As you can see there is a menu macro whose content supports wiki syntax (including scripting!). The Menu Application uses this menu macro. When you create a new menu (a new entry in the Menu Application) you get a WYSIWYG editor for the "Menu Structure" property. Whatever you put there is passed as the content of the menu macro. In other words, the "Menu Structure" is the content of the menu macro. So you can insert any scripting macro through the WYSIWYG editor or you can switch to source and write there the code you need. The only 'requirement' is that your code will generate in the end an HTML list. Checkout the "Hierarchy Panel" example. Hope this helps, Marius On Fri, Apr 18, 2014 at 11:53 AM, Jeremie BOUSQUET <[email protected]> wrote:
Hello,
I used the Menu Application [1] to define a horizontal menu, after page header, and it's very nice and very user-friendly.
I wonder if it could (easily) be feasible, to have the content ("Menu Structure") of the menu rendered ? My point would be to put some velocity scripting in it, to achieve more dynamic menus (display parts depending on user rights, generate some lists of items, etc). A bit like the jsx/ssx extensions do.
I had a look but I didn't find where the "magic" operates :)
Thanks, Jeremie
[1] http://extensions.xwiki.org/xwiki/bin/view/Extension/Menu+Application _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Hi Marius, I am getting an "org.xwiki.rendering.macro.MacroExecutionException: Nested scripts are not allowed" error when I try the "Hierarchy Panel" example (We are using XWiki 5.4.3) What am I doing wrong? -- View this message in context: http://xwiki.475771.n2.nabble.com/Menu-Application-rendering-content-tp75901... Sent from the XWiki- Users mailing list archive at Nabble.com.
On Apr 19, 2014 8:53 AM, "Hamster" <[email protected]> wrote:
Hi Marius,
I am getting an "org.xwiki.rendering.macro.MacroExecutionException: Nested scripts are not allowed" error when I try the "Hierarchy Panel" example
(We
are using XWiki 5.4.3)
What am I doing wrong?
Can you please be more precise? How, when and where do you get this error? What is the value of the "Menu Structure" property (the wiki syntax source)?
-- View this message in context:
http://xwiki.475771.n2.nabble.com/Menu-Application-rendering-content-tp75901...
Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Hi Marius, Originally I simply copy-pasted the example code: {{menu type="vertical collapsible"}} {{velocity}} #set ($depth = 3) #set ($limit = 10) #macro (children $parentDoc $level) #foreach ($child in $parentDoc.getChildren($limit, 0)) #set ($childDoc = $xwiki.getDocument($child)) $stringtool.repeat('*', $level) {{html}} $escapetool.xml($childDoc.plainTitle) <$childDoc.getURL()> {{/html}} #if ($level < $depth) #children ($childDoc $mathtool.add($level, 1)) #end #end #end #children ($doc 1) {{/velocity}} {{/menu}} But that generated the "nested scripts" error. I then checked the object, and noticed that there's a UIEntensionClass with the following code: {{velocity}} #panelheader("Navigation") {{menu type="vertical collapsible"}}{{include reference="xwiki:Menu.Navigation" /}}{{/menu}} #panelfooter() {{/velocity}} So I changed the original example code to... {{velocity}} #set ($depth = 3) #set ($limit = 10) #macro (children $parentDoc $level) #foreach ($child in $parentDoc.getChildren($limit, 0)) #set ($childDoc = $xwiki.getDocument($child)) $stringtool.repeat('*', $level) {{html}} $escapetool.xml($childDoc.plainTitle) <$childDoc.getURL()> {{/html}} #if ($level < $depth) #children ($childDoc $mathtool.add($level, 1)) #end #end #end #children ($doc 1) {{/velocity}} ...which solved the error. -- View this message in context: http://xwiki.475771.n2.nabble.com/Menu-Application-rendering-content-tp75901... Sent from the XWiki- Users mailing list archive at Nabble.com.
Hi, Thanks Marius, I simply forgot to try adding "{{velocity}}" macro, I was thinking too much it would be like css extensions ! :) BR, Jeremie 2014-04-18 16:43 GMT+02:00 Marius Dumitru Florea < [email protected]>:
Hi Jeremie,
The "Menu Structure" is rendered!
Take a look at http://extensions.xwiki.org/xwiki/bin/view/Extension/Menu+Application#HExamp... . As you can see there is a menu macro whose content supports wiki syntax (including scripting!). The Menu Application uses this menu macro. When you create a new menu (a new entry in the Menu Application) you get a WYSIWYG editor for the "Menu Structure" property. Whatever you put there is passed as the content of the menu macro. In other words, the "Menu Structure" is the content of the menu macro. So you can insert any scripting macro through the WYSIWYG editor or you can switch to source and write there the code you need. The only 'requirement' is that your code will generate in the end an HTML list. Checkout the "Hierarchy Panel" example.
Hope this helps, Marius
On Fri, Apr 18, 2014 at 11:53 AM, Jeremie BOUSQUET <[email protected]> wrote:
Hello,
I used the Menu Application [1] to define a horizontal menu, after page header, and it's very nice and very user-friendly.
I wonder if it could (easily) be feasible, to have the content ("Menu Structure") of the menu rendered ? My point would be to put some velocity scripting in it, to achieve more dynamic menus (display parts depending on user rights, generate some lists of items, etc). A bit like the jsx/ssx extensions do.
I had a look but I didn't find where the "magic" operates :)
Thanks, Jeremie
[1] http://extensions.xwiki.org/xwiki/bin/view/Extension/Menu+Application _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (3)
-
Hamster -
Jeremie BOUSQUET -
Marius Dumitru Florea