+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Custom Field on Forum Post

Custom Field on Forum Post

4 posts, 0 answered
  1. Richard
    Richard avatar
    14 posts
    Registered:
    23 Apr 2012
    09 Jul 2012
    Link to this post
    Hi,

    I have added a custom field onto both the Forum Thread and Forum Post items.  However in my code when I try to extract the value of that field I cannot call GetValue on the ForumPost class but am able to on ForumThread.  Is this a bug or am I just missing something completely obvious?

    Thanks

    Update:

    I've also noticed that I cannot dynamically create custom fields through code as discussed in this thread:

    http://www.sitefinity.com/devnet/forums/sitefinity/sdk/custom-page-attributes.aspx 
  2. Randy Hodge
    Randy Hodge avatar
    96 posts
    Registered:
    03 Nov 2014
    12 Jul 2012
    Link to this post
    Hi, Richard.

    Thank you for contacting us.

    Unfortunately, the GetValue extension method has not been implemented for the ForumPost class. I will need to check to see if this is expected or a bug and I will get back as soon as I know.

    To create custom fields in pages you must first make PageData into a dynamic meta type:
    var metaManager = Telerik.Sitefinity.Data.Metadata.MetadataManager.GetManager();
     
    if (metaManager.GetMetaType(typeof(PageData)) == null)
    {
        var type = metaManager.CreateMetaType(typeof(PageData));
        metaManager.SaveChanges();
    }
     
    App.WorkWith().DynamicData().Type(typeof(PageData)).Field().TryCreateNew("MyPageDataField", typeof(string)).SaveChanges(true);
     
    var dynamicContent = App.WorkWith().DynamicData().Fields().Where(dc => dc.FieldName == "MyPageDataField").Get();
     
    var pg = App.WorkWith().Pages().Where(pk => pk.Title == "pagetitle").Get().SingleOrDefault();
     
    pg.Page.SetValue("MyPageDataField", "somevalue");

    I hope this works for you.

    Regards,
    Randy Hodge
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Randy Hodge
    Randy Hodge avatar
    96 posts
    Registered:
    03 Nov 2014
    13 Jul 2012
    Link to this post
    Hello, Richard.

    Just to follow up, the issue with GetValue and ForumPost is a bug which will be fixed in an upcoming release. You can follow it in PITS here.

    I apologize for any inconvenience this causes you. Please let us know if we can be of further assistance.

    All the best,
    Randy Hodge
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  4. Bonny
    Bonny avatar
    58 posts
    Registered:
    11 Nov 2016
    01 Jul
    Link to this post
    Hi,

    I am writing here to let you know that the issue is fixed in the latest internal build!
    You can now create custom fields for forum posts using the API.
    If there are any issues with this, don't hesitate to contact us.

    Regards,
    Bonny
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
4 posts, 0 answered