how to declare a variable in kentico in transformations

raj k asked on November 19, 2014 15:03

how to declare a variable in kentico

Correct Answer

Jan Hermann answered on November 20, 2014 08:07

Hi Ryan,

here it is -> https://docs.kentico.com/display/K8/Adding+custom+macro+fields

Best regards,
Jan Hermann

0 votesVote for this answer Unmark Correct answer

Recent Answers


Jan Hermann answered on November 19, 2014 15:40

Hello,

since you tagged it as macro, you probably mean Text/XML transformations and in these transformations no declaration is needed:

{%
someNewVariable = "someValue";
%}

Best regards,
Jan Hermann

0 votesVote for this answer Mark as a Correct answer

Ryan R answered on November 19, 2014 18:17

This is great Jan, but how/where can I declare a variable that is globally available?

I need to have a master page with all of my variables (current prices, fees, etc) that can easily be accessed and maintained in one place (or better yet pull from a spreadsheet). Then I need to be able to call the variables anywhere.

In other words: how can I create a global variable that works similar to {% CurrentDate %} that can be used anywhere?

If I declare and call on the same page it works, but if I declare on my master page and then call later it does not work.

0 votesVote for this answer Mark as a Correct answer

Ryan R answered on November 20, 2014 16:59

This is perfect, thanks Jan!

0 votesVote for this answer Mark as a Correct answer

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