2017-10-16 41 views
0

我在靜態文本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> 

第一行顯示呈現頁面上的文檔名稱(其餘代碼工作正常)。我使用Kentico 10

回答

3

添加return語句,讓您的線路如下:

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