Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Month Comparison Macro View modes: 
User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 1/19/2012 11:52:51 PM
   
Month Comparison Macro
I'd like to create a macro in the Visbility of a webpart to set the visibility if the Month # is 1-4. Simple logic in C# would be:
if (Now.Month >= 1 && Now.Month <=4)
{
// do my work
}

How do I get that similar syntax in a macro without creating a custom macro?

I know I can get the month pretty easy {% Now.Month %} but how do they all work together or how can I perform those comparison operations?

User avatar
Kentico Support
Kentico Support
kentico_janh - 1/20/2012 2:38:31 AM
   
RE:Month Comparison Macro
Hello,

Actually, you wrote a working example! When I paste this code as a Visibility macro, it works as you expected:
{%

if (Now.Month >= 1 && Now.Month <= 4)
{
return true;
}
else {
return false;
}

%}

Best regards,
Jan Hermann

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 1/20/2012 8:25:59 AM
   
RE:Month Comparison Macro
So you're saying I can write C# in the macro window? I thought it was a different engine like F or K?

User avatar
Kentico Support
Kentico Support
kentico_janh - 1/23/2012 1:15:54 AM
   
RE:Month Comparison Macro
Hello,

No, you can't, but K# is based on a syntax of C#, so some simplier K# scripts can look same as they are written in C#. For more information, please follow the link below to our documentation:

http://devnet.kentico.com/docs/devguide/index.html?ksharp_syntax.htm

Best regards,
Jan Hermann