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
<thomas.morta...@xwiki.com> 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#HScriptingAPI28since6.1RC129.
>
> On Tue, Jan 13, 2015 at 10:09 AM, Hamster <teun...@hotmail.com> 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.html
>> Sent from the XWiki- Users mailing list archive at Nabble.com.
>> _______________________________________________
>> users mailing list
>> users@xwiki.org
>> http://lists.xwiki.org/mailman/listinfo/users
>
>
>
> --
> Thomas Mortagne



-- 
Thomas Mortagne
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to