Hi Gerritjan,
see below
On 07/16/2011 03:58 PM, Gerritjan Koekkoek wrote:
Hi,
I would like to conditional show pages based on request parameter
But i'm struggling with the fact if there is not a request parameter
{{velocity}}
#if("$request.cntryCode" != "es")
{{include document="Sandbox.TryCr"/}}
#else
{{include document="Sandbox.TryEs"/}}
#end
{{/velocity}}
So if the request parameter cntryCode is not "es" (so anything else) show first
page TryCr otherwise show page TryEs
But what if no parameter is givven; then I would like to show TryEs (assume parameter was
"es"
change condition to:
"$!request.cntryCode" != "" && "$!request.cntryCode"
!= "es"
if it's not empty string or non present or not es ($! in front of the
var means if it's null nothing will be displayed. See info here
http://www.jajakarta.org/velocity/velocity-1.2/docs/user-guide.html#Quiet Reference
Notation
<http://www.jajakarta.org/velocity/velocity-1.2/docs/user-guide.html#Quiet%20Reference%20Notation>
)
Any suggestions
second question; how can i best use the parameter to avoid extensive coding;
Instead of
#if("$request.cntryCode" != "cr")
{{include document="Sandbox.Trycr"/}}
#elseif("$request.cntryCode" != "hn")
{{include document="Sandbox.Tryhn"/}}
#elseif("$request.cntryCode" != "el")
{{include document="Sandbox.Tryel"/}}
#elseif("$request.cntryCode" != "ng")
{{include document="Sandbox.Tryng"/}}
#else
{{include document="Sandbox.TryEs"/}}
#end
I would only think i need to concatenate the parameter to the end of the documentname
Tryxx to get the good document
Wait, if I understand well this code, this means: if request country
code is _not_ cr, then include Sandbox.Trycr. Concatenation sounds good,
but with what? because concatenating the request param at the end of the
doc name would mean if the country code is cr, include Trycr.
In any case, for concatenation this should work:
{{include document="Sandbox.Try$!{request.cntryCode}" /}}
, using formal notation to prevent velocity interpreter from getting
confused by surrounding text (see info here about formal notation
http://www.jajakarta.org/velocity/velocity-1.2/docs/user-guide.html#Formal
Reference Notation
<http://www.jajakarta.org/velocity/velocity-1.2/docs/user-guide.html#Formal%20Reference%20Notation>
).
Have fun,
Anca
Hope somebody can help me
Gerritjan
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users