Hi,
unfortunatelly, you did not mention where you would like to use this macro. Since you have 4.x version the best way how to achieve your goal is using
custom macro.
You can use for example this code:
public static string ResolveCustomMacro(MacroResolver sender, string expression, out bool match)
{
match = false;
string result = expression;
string menuclass = "";
// Add your custom macro evaluation
switch (expression.ToLower())
{
case "setclassname":
match = true;
// Set class name
if (String.IsNullOrEmpty(CMSContext.CurrentDocument.DocumentMenuClass))
{
menuclass = "green";
}
else
{
menuclass = CMSContext.CurrentDocument.DocumentMenuClass.ToString();
}
result = menuclass;
break;
}
return result;
}
and you can call this macro using expression:
{% ProcessCustomMacro("setclassname", "") %}Since version 5.5 hotfix 10 you can use instead of custom macro following one:
{%if (documentmenuclass == "") { "green" } else { documentmenuclass }%}Best regards,
Ivana Tomanickova