0

我使用 Sitecore 7,在代码中我看到了这一行

 public static ID HelpLinks
    {
        get { return GetIdFromConfig("aer.ProductDetails.HelpLinks"); }
    }

开发者用这个函数定义这条线

 static ID GetIdFromConfig(string key)
    {
        try
        {
            return new ID(Sitecore.Configuration.Settings.GetSetting(key));
        }
        catch (Exception ex)
        {
            Sitecore.Diagnostics.Log.Warn(String.Format("GetIdFromConfig (key='{0}'): not found ", key), ex, "aed.Classes.ConfigID");
            return null;
        }
    }

我想知道它是如何定义的

aer.ProductDetails.HelpLinks

为了获得 Sitecore 唯一 ID 并在其他模板中使用它。有人知道它是如何定义的吗?

4

1 回答 1

1

在配置中的设置部分(web.config 或解决方案的 Include 文件夹中的某些包含文件)中的某处,您需要使用该名称定义该键。

应该有这样的东西:

<sitecore>
  <settings>
    <setting name="aer.ProductDetails.HelpLinks" value="sitecoreID" />
  </settings>
</sitecore>

其中 sitecoreID 是 Sitecore ID 格式,例如{DE3A698F-1D7F-4C43-B797-162C5811E270}

于 2016-02-19T09:10:50.107 回答