Search code examples
sitecoresitecore7.2weblog

Added a Field to WeBlog Entry template, trying to get the field in Category.ascx.cs


I have followed the steps in the following link Template Settings and created custom templates for Entry, Comment and Category. To the Custom Entry Template, I have added an additional field. I have a requirement to display it in the Categories.ascx. I am able to override the Categories.ascx but I am unable to get the value of the added field using WeBlog's API. Here's the code that I am using. But the issue is that the Class EntryItem doesn't have the additional field that I have added. Is there a way to read this field using WeBlog API?

EntryItem[] blogEntries = ManagerFactory.EntryManagerInstance.GetBlogEntries();

Solution

  • EntryItem inherits from CustomItem I believe, so you can use the InnerItem Property to get access to the actual Item. Your field should then be available like this:

     entryItem.InnerITem["YouField"];
    

    You can use a field renderer in the Categories.ascx file to display the value of you field and use data binding to get the item assigned to the field renderer.

     <sc:FieldRenderer ID="FieldRenderer1" runat="server" FieldName="YourField"  item='<%# entryItem.innerItem %>'/>