Re: [xwiki-users] Context Macro Broken?
Does it work if you change... {{context document="wiki1:Main.WebHome"}}#if ($hasEdit){{/context}}[[Wiki1>>wiki1:Main.WebHome]]#end ..to: {{context document="wiki1:Main.WebHome"}}#if ($hasEdit)[[Wiki1>>wiki1:Main.WebHome]]#end{{/context}} -- View this message in context: http://xwiki.475771.n2.nabble.com/Context-Macro-Broken-tp7593647p7593648.htm... Sent from the XWiki- Users mailing list archive at Nabble.com.
What you have in your example cannot work, you have to understand how Velocity macro work: it executes the Velocity in the macro content and then the result is parsed and executed as wiki syntax, Velocity engine does not have any idea what {{context}} mean, its just plain text for it and will end up in the result of Velocity execution as it is. To make the context macro work in your use case you should cut your Velocity macro in pieces, something like: {{velocity}} #panelheader('Product Wikis') {{/velocity}} [[Company Main>>url:http://172.30.29.50:8080/xwiki/bin/view/Main/]] {{context document="wiki1:Main.WebHome"}}{{velocity}}#if ($hasEdit)[[Wiki1>>wiki1:Main.WebHome]]#end{{/velocity}}{{/context}} {{context document="wiki2:Main.WebHome"}}{{velocity}}#if ($hasEdit)[[Wiki2>>wiki2:Main.WebHome]]#end{{/velocity}}{{/context}} {{context document="wiki3:Main.WebHome"}}{{velocity}}#if ($hasEdit)[[Wiki3>>wiki3:Main.WebHome]]#end{{/velocity}}{{/context}} {{velocity}} #panelfooter() {{/velocity}} But unless you use case if more complex than testing $hasEdit you should use right service API instead of switching the context like that, see http://extensions.xwiki.org/xwiki/bin/view/Extension/Security+Module#HScript.... On Tue, Jan 13, 2015 at 10:09 AM, Hamster <[email protected]> wrote:
Does it work if you change...
{{context document="wiki1:Main.WebHome"}}#if ($hasEdit){{/context}}[[Wiki1>>wiki1:Main.WebHome]]#end
..to:
{{context document="wiki1:Main.WebHome"}}#if ($hasEdit)[[Wiki1>>wiki1:Main.WebHome]]#end{{/context}}
-- View this message in context: http://xwiki.475771.n2.nabble.com/Context-Macro-Broken-tp7593647p7593648.htm... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
Actually you have to use security service since $hasEdit is not going to change whatever you put in the context macro because this is just a Velociy variable set before this page is executed, it's not resetted by context macro. On Tue, Jan 13, 2015 at 1:17 PM, Thomas Mortagne <[email protected]> wrote:
What you have in your example cannot work, you have to understand how Velocity macro work: it executes the Velocity in the macro content and then the result is parsed and executed as wiki syntax, Velocity engine does not have any idea what {{context}} mean, its just plain text for it and will end up in the result of Velocity execution as it is.
To make the context macro work in your use case you should cut your Velocity macro in pieces, something like:
{{velocity}} #panelheader('Product Wikis') {{/velocity}}
[[Company Main>>url:http://172.30.29.50:8080/xwiki/bin/view/Main/]]
{{context document="wiki1:Main.WebHome"}}{{velocity}}#if ($hasEdit)[[Wiki1>>wiki1:Main.WebHome]]#end{{/velocity}}{{/context}}
{{context document="wiki2:Main.WebHome"}}{{velocity}}#if ($hasEdit)[[Wiki2>>wiki2:Main.WebHome]]#end{{/velocity}}{{/context}}
{{context document="wiki3:Main.WebHome"}}{{velocity}}#if ($hasEdit)[[Wiki3>>wiki3:Main.WebHome]]#end{{/velocity}}{{/context}}
{{velocity}} #panelfooter() {{/velocity}}
But unless you use case if more complex than testing $hasEdit you should use right service API instead of switching the context like that, see http://extensions.xwiki.org/xwiki/bin/view/Extension/Security+Module#HScript....
On Tue, Jan 13, 2015 at 10:09 AM, Hamster <[email protected]> wrote:
Does it work if you change...
{{context document="wiki1:Main.WebHome"}}#if ($hasEdit){{/context}}[[Wiki1>>wiki1:Main.WebHome]]#end
..to:
{{context document="wiki1:Main.WebHome"}}#if ($hasEdit)[[Wiki1>>wiki1:Main.WebHome]]#end{{/context}}
-- View this message in context: http://xwiki.475771.n2.nabble.com/Context-Macro-Broken-tp7593647p7593648.htm... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
-- Thomas Mortagne
It doesn't even work if I do something as simple as: {{context document="OtherSpace.WebHome"}} [[WebHome]] {{/context}} or with an image. The image is broken when this is entered in, for example, Main.Context Test: {{context document="Sandbox.WebHome"}} image:XWikiLogo.png {{/context}} -- View this message in context: http://xwiki.475771.n2.nabble.com/Context-Macro-Broken-tp7593647p7593660.htm... Sent from the XWiki- Users mailing list archive at Nabble.com.
If those example don't work then indeed there seems to be some regression in context macro. Would be great if you could create an issue on http://jira.xwiki.org indicating in which XWiki version you have the bug. On Tue, Jan 13, 2015 at 7:58 PM, cmherman <[email protected]> wrote:
It doesn't even work if I do something as simple as:
{{context document="OtherSpace.WebHome"}} [[WebHome]] {{/context}}
or with an image. The image is broken when this is entered in, for example, Main.Context Test:
{{context document="Sandbox.WebHome"}} image:XWikiLogo.png {{/context}}
-- View this message in context: http://xwiki.475771.n2.nabble.com/Context-Macro-Broken-tp7593647p7593660.htm... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
Hm. If ($hasEdit) can't be recontextualized I guess I'll have to expand my options. Thanks for the link. BTW, the problem I had with opening and closing the velocity macro is that, in a panel, closing the velocity macro signals the end of the panel to the CSS. The entire contents of the panel appear in the sidebar but only the header is enclosed in the box. The rest of the panels contexts float in whitespace between the Product Wikis panel box and the next panel's box. So, functional but ugly. -- View this message in context: http://xwiki.475771.n2.nabble.com/Context-Macro-Broken-tp7593647p7593662.htm... Sent from the XWiki- Users mailing list archive at Nabble.com.
On Tue, Jan 13, 2015 at 8:09 PM, cmherman <[email protected]> wrote:
Hm. If ($hasEdit) can't be recontextualized I guess I'll have to expand my options. Thanks for the link.
BTW, the problem I had with opening and closing the velocity macro is that, in a panel, closing the velocity macro signals the end of the panel to the CSS.
Hmm this is not really related to {{velocity}} macro but to what #panelheader produces actually (there is no way for the css to even know there was a {{velocity}} macro at all). We really need a more "modern" {{panel}} macro instead of that crappy velocity based #panelheader/#panelfooter... Anyway as I told you for the use case you described in your example there is no needed to cut the velocity content if you use the proper rights API.
The entire contents of the panel appear in the sidebar but only the header is enclosed in the box. The rest of the panels contexts float in whitespace between the Product Wikis panel box and the next panel's box. So, functional but ugly.
-- View this message in context: http://xwiki.475771.n2.nabble.com/Context-Macro-Broken-tp7593647p7593662.htm... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
I can't believe I didn't state my version. Geez. Enterprise 6.3 Posting the JIRA issue link for reference: http://jira.xwiki.org/i#browse/XE-1459 <http://jira.xwiki.org/i#browse/XE-1459> -- View this message in context: http://xwiki.475771.n2.nabble.com/Context-Macro-Broken-tp7593647p7593664.htm... Sent from the XWiki- Users mailing list archive at Nabble.com.
participants (3)
-
cmherman -
Hamster -
Thomas Mortagne