Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Compare Query string with a Macro View modes: 
User avatar
Member
Member
Chanan - 3/17/2011 9:07:30 AM
   
Compare Query string with a Macro
I am trying to compare a query string with a macro but I am not getting the expected results. The code is:

User is: {%user%}<br/>
Are they equal: {%if ({?user?} == "chanan") { "Yes" } else { "No" }%}<br />


The results are when going to the page with ?user=chanan and logged in as chanan are:

User is: chanan
Are they equal: No
Is Username equal to chanan: Yes
Are they equal with nested macros: No

while the expected results should be (I am unsure about the 4th line, I was trying it to see if it helps):
User is: chanan
Are they equal: Yes
Is Username equal to chanan: Yes



User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 3/17/2011 9:48:07 AM
   
RE:Compare Query string with a Macro
Hi,

if you need to compare a string with a query parameter you can do it with following code:

User is: {%user%}<br/>
Are they equal: {%if (user == "administrator") { "Yes" } else { "No" }%}<br />
Is Username equal to administrator: {%if (UserName == "administrator") { "Yes" } else { "No" }%} <br/>
<br/>


Result:
User is: administrator
Are they equal: Yes
Is Username equal to administrator: Yes

Best regards,
Ivana Tomanickoava

User avatar
Member
Member
Chanan - 3/17/2011 10:05:40 AM
   
RE:Compare Query string with a Macro
Ah ok, that makes sense.... It might be worth to update the documentation, that is not very clear.