I'm very new to Kentico and C# for that matter, but have been all over here and the internet in general and been unable to figure out how to do something so simple.
I'd like to conditionally set a variable to a string to check against in my markup. I'm able to set the variable, but every method I use to do so ends up outputting the String when it's declared as well. I've tried using the standard C# "String" syntax when I declare as well as many other variations and nothing seems to work. How can I sanitize the string value in my macro to only show up when I call the variable?
{% if(DisplayType == 0){ spClass = EmbeddedWrapperClass; altPos = "right"; }
in K# I add a return; to keep the string from being outputted.
{% if (DisplayType == 0) { spClass = EmbeddedWrapperClass; altPos = "right"; return; } |(identity)GlobalAdministrator%}
I ran across a similar need a while back. It is more cumbersome than you'd imagine, but this works:
http://devnet.kentico.com/questions/variables-in-transformations
In my opinion, I think the best thing to do is create a custom transformation method in code behind which accepts your parameter, much cleaner, reusable approach.
Please, sign in to be able to submit a new answer.