Keith
Keith

Reputation: 4137

how to grab a field from a folder in sitecore using c#

I have a left nav menu that I use to display the folder/page in another div.

<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>

Without creating another field on the sublayout, duplicating the name of the folder, how can I grab the value of "Page Title" field from the folder that the item is in?

Sitecore/
   Home/
     Products/
        Folder1/
           Item1
           Item2
           Item3

Currently, the "Title" gets displayed but nothing shows up for "Page Title" since I don't have a field in the same sublayout. The "Page Title" is a field on the direct folder above it ( have about 7 folders and <%=Sitecore.Context.Item.Parent.DisplayName %> won't work since it is not the same value that is used in "Page Title" )

Upvotes: 0

Views: 291

Answers (1)

Vlad Iobagiu
Vlad Iobagiu

Reputation: 4118

You can use: <%=Sitecore.Context.Item.Parent["Page Title"]%> if you have on Folder1 item a field named Page Title.

Upvotes: 1

Related Questions