k# rendering macro code

paul krysiak asked on March 30, 2017 21:15

Hello everyone
I am putting K# in a text filed and kentico is just rendering the macro code. this is the macro i put in {% if (MembershipContext.AuthenticatedUser){return "Welcome"+MembershipContext.AuthenticatedUser.DisplayName;}else{return "Aboutlourm ipsum";} #%} this is what displays

{% if (MembershipContext.AuthenticatedUser){
return "
Welcome
"+MembershipContext.AuthenticatedUser.DisplayName;
}else{
return "
About
lourm ipsum

";
}

Ideas?
Thanks
PK

Correct Answer

Roman Hutnyk answered on March 31, 2017 07:55

Where did you put it? Transformation? What type?

0 votesVote for this answer Unmark Correct answer

Recent Answers


Rui Wang answered on March 31, 2017 05:54 (last edited on December 10, 2019 02:30)

K# doesn't need return, you can display text + value directly.

{% if (MembershipContext.AuthenticatedUser){ %}
Welcome {% MembershipContext.AuthenticatedUser.DisplayName %}
{% }else{ %}
About lourm ipsum
{% } |(identity)GlobalAdministrator%} 
0 votesVote for this answer Mark as a Correct answer

paul krysiak answered on March 31, 2017 19:57

I put it in rich text editor attached to a page type. It gave the code option in the tool bar.

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on March 31, 2017 20:00

Do you use any web part in order to present that field on the page? If so, please make sure it has not "Disable macro" checked in web part settings.

0 votesVote for this answer Mark as a Correct answer

paul krysiak answered on April 4, 2017 15:30

I think I found the issue.
I didn't realize the content was being rendered through a repeater. The macro is being rendered through a transformation. I think it's just seeing it as text.
Thanks for all your help
Paul

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.