How to programmatically access label for custom field in blo

Posted by Community Admin on 04-Aug-2018 22:18

How to programmatically access label for custom field in blog

All Replies

Posted by Community Admin on 16-Mar-2012 00:00

Telerik,

Using the native API, I am able to retrieve values from custom fields in a blog post using
DataExtensions.GetValue(dataItem, fieldName).  My question is, how can I get the associated label for this fieldname?  For example, In a blog post, I have a custom field named "question1".  The label for question1 is "Name an animal with 4 legs".   So using the GetValue extension method, I can get the value for this question, but how do I programmatically get the "Name an animal with 4 legs" part of question1?  Please advise using native API syntax.

Here's some simplified example code:

1.BlogsManager blogsManager = BlogsManager.GetManager();
2.// get all published blogs items
3.var allBlogs = blogsManager.GetBlogPosts().Where(b => b.Status == ContentLifecycleStatus.Live).ToList();
4.(string)DataExtensions.GetValue(allBlogs, "question1");

Thank you.

Mark

Posted by Community Admin on 21-Mar-2012 00:00

Hello Mark,

Can you please share with us the widget template you are currenlty using for your blog posts widget so we can give you a more specific advice? Please note that by adding the custom field on your template this will display just the value of the field, can you please make sure you have not added the label separately?

Regards,
Boyan Barnev
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

This thread is closed