Is there a way to compare two macros in Kentico?
I have a disclaimer message that I only want visible when the page being viewed hasn't been translated into the language that has been selected for the site.
I'm using a static text webpart for the disclaimer message, and trying to set its visibility based on the page's culture {%cmscontext.currentdocumentculture.culturecode%} not equaling the selected view culture {%currentculture%}.
I tried: {%cmscontext.currentdocumentculture.culturecode|(notequals){(1)%currentculture%(1)}%}
But this resolves开发者_运维百科 as true no matter what culture has been selected. Any ideas?
It depends on what version of Kentico you are using.
If you are using 5.5+, you have the option to use Nested Macros. Here's a quote from Martin Hejtmanek about it:
If you worked with some more complex macros, you know that you can use something like this:
{%DocumentName|(equals)Home|(truevalue){?param?}%} But you cannot do something like this in 5.0:
{%DocumentName|(equals)Home|(truevalue){%param%}%}
The difference is in type of macros. For performance reasons (faster processing) we didn't allow nesting of the same kind of macros so we can keep the macro regex as simple as possible.
With 5.5, there is an option to solve this. We offer using of coupled brackets to allow nesting of macros of the same type, an example explains this best:
{%DocumentName|(equals)Home|(truevalue){(1)%param%(1)}%}
What you do is you can put a number between the macro bracket and the type character, which makes it easier for you to see where the end of your expression is, and also possible to the engine to see it correctly. The number does not have any information value, it is just a number to detect the match. It can be any non-negative integer.
So previously, you could nest different Types of macros - eg: you could nest a Path macro within an Expression macro. But now in version 5.5 you can nest the same Type of macro.
Cheers, Lance
精彩评论