Kentico 在静态文本中声明变量在页面上显示文档名称

Kentico 在静态文本中声明变量在页面上显示文档名称,kentico,Kentico,我在静态文本web部件文本字段中声明变量时遇到问题。当我使用这样的代码时: {% doc = Documents.WithAllData[CurrentDocument.Children["Hero"].Children[0].GetValue("NodeAliasPath")]; #%} <p> {% if (!string.IsNullOrEmpty(doc.HeroButtonLabel)) { %} <a class="btn btn-secondary ar

我在静态文本web部件文本字段中声明变量时遇到问题。当我使用这样的代码时:

{% doc = Documents.WithAllData[CurrentDocument.Children["Hero"].Children[0].GetValue("NodeAliasPath")]; #%}

<p>
  {% if (!string.IsNullOrEmpty(doc.HeroButtonLabel)) { %}
  <a class="btn btn-secondary arrow" href="{% doc.HeroUrl #%}">
    {% doc.HeroButtonLabel #%}
  </a>
  {% } #%}
  {% if (!string.IsNullOrEmpty(doc.HeroUrl2Label)) { %}
  <a class="btn btn-secondary arrow" href="{% doc.HeroUrl2 #%}">
    {% doc.HeroUrl2Label #%}
  </a>
  {% } #%}
</p>
{%doc=Documents.WithAllData[CurrentDocument.Children[“Hero”]。Children[0]。GetValue(“NodeAliasPath”)];#%}

{%if(!string.IsNullOrEmpty(doc.HeroButtonLabel)){%}
{% } #%}
{%if(!string.IsNullOrEmpty(doc.HeroUrl2Label)){%}
{% } #%}


第一行显示呈现页面上的文档名称(其余代码工作正常)。我使用Kentico 10。

添加一个return语句,这样您的行内容如下:

{% 
  doc = Documents.WithAllData[CurrentDocument.Children["Hero"].Children[0].GetValue("NodeAliasPath")];
  return;
#%}