Custom Field on Forum Post

Posted by Community Admin on 04-Aug-2018 13:11

Custom Field on Forum Post

All Replies

Posted by Community Admin on 09-Jul-2012 00:00

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 

Posted by Community Admin on 12-Jul-2012 00:00

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

Posted by Community Admin on 13-Jul-2012 00:00

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

Posted by Community Admin on 01-Jul-2016 00:00

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
 

This thread is closed