如何使用c#从sitecore中的文件夹中获取字段



我有一个左导航菜单,用于显示另一个分区中的文件夹/页面。

<div class="titleContainer">
     <div class="folder"><sc:FieldRenderer FieldName="Page Title" runat="server" /></div>
     <div class="mainpage"><sc:FieldRenderer FieldName="Title" runat="server" /></div>
</div>

如果不在子网站上创建另一个字段,复制文件夹的名称,我如何从项目所在的文件夹中获取"页面标题"字段的值?

Sitecore/
   Home/
     Products/
        Folder1/
           Item1
           Item2
           Item3

目前,"标题"会被显示,但"页面标题"不会显示,因为我在同一个子层中没有字段。"页面标题"是其上方直接文件夹上的一个字段(大约有7个文件夹,<%=Sitecore.Context.Item.Parent.DisplayName%>将不起作用,因为它与"页面标题"中使用的值不同)

您可以使用:<%=Sitecore.Context.Item.PParent["Page Title"]%>如果您在Folder1项目上有一个名为Page Title的字段。

最新更新