根据 Kentico 中的页面类别设置 webpart 可见性
Set webpart visibility based on page category in Kentico
我有一个包含静态 HTML Web 部件的页面,我想根据页面类别的值设置其可见性。如果 category = "ABC" 则使其可见,如果不可见则使其不可见。类别值是通过“属性”选项卡设置的。我在下面尝试了这两个宏,但都没有用。感谢您的帮助!
{%if(CurrentDocument.Categories.DisplayNames=="ABC"){ return true; } else { return false; } #%}
或
{%if(CurrentDocument.Categories.DisplayNames.Contains("ABC")){ return true; } else { return false; } #%}
你可以用下面的宏来完成(而且不需要 IF 条件):
{% CurrentDocument.IsInCategories("ABC;ABCD") %}
可以用分号列出多个类别。
我有一个包含静态 HTML Web 部件的页面,我想根据页面类别的值设置其可见性。如果 category = "ABC" 则使其可见,如果不可见则使其不可见。类别值是通过“属性”选项卡设置的。我在下面尝试了这两个宏,但都没有用。感谢您的帮助!
{%if(CurrentDocument.Categories.DisplayNames=="ABC"){ return true; } else { return false; } #%}
或
{%if(CurrentDocument.Categories.DisplayNames.Contains("ABC")){ return true; } else { return false; } #%}
你可以用下面的宏来完成(而且不需要 IF 条件):
{% CurrentDocument.IsInCategories("ABC;ABCD") %}
可以用分号列出多个类别。