Handling CheckBox List in 7.6 with new Property Value Converters
Hi
Still getting my head around the new value property converters.
Im trying to access a CheckBox List. Using Smart Blog and adapting how it usually gets those prevalues.
I have the following code:
// Get this blogs root, does not use an id because there may be more thanone blog
IPublishedContent objBlogRoot = Model.Content.AncestorOrSelf("SmartBlogBlog");
// Get the posts in this blog
IEnumerable<IPublishedContent> colPosts = objBlogRoot.Descendants("SmartBlogPost").OrderBy("updateDate").Where(x => x.IsVisible() == true);
// Create the tag dictionary
Dictionary<String, Int32> colCategories = new Dictionary<String, Int32>();
// Loop through all the posts then loop through their tags to add to the tag dictionary
foreach (IPublishedContent objPost in colPosts)
{
String[] colCategoryNames;
if (!String.IsNullOrEmpty(objPost.GetPropertyValue<String>("smartBlogCategory")))
{
colCategoryNames = objPost.GetPropertyValue<String>("smartBlogCategory").Split(',');
}
else
{
colCategoryNames = new String[0];
}
foreach (String strCategory in colCategoryNames)
{
if (colCategories.ContainsKey(strCategory))
{
colCategories[strCategory]++;
}
else
{
colCategories.Add(strCategory, 1);
}
}
}
I belive this section needs changing to access the Property Value Converter?
String[] colCategoryNames;
if (!String.IsNullOrEmpty(objPost.GetPropertyValue<String>("smartBlogCategory")))
{
colCategoryNames = objPost.GetPropertyValue<String>("smartBlogCategory").Split(',');
}
else
{
colCategoryNames = new String[0];
}
Unsure how to access the String array in the value? Tried casting it to a String[] but just get null value. Can someone point me in the right direction. The online documents don't outline Checkbox list.
Late to the party but for this checkboxlist issue, but for 7.6+ if the EnablePropertyValueConverters option is set to true in the umbracoSetting.config then you can cast a checheckboxlist as an IEnumerable
Handling CheckBox List in 7.6 with new Property Value Converters
Hi
Still getting my head around the new value property converters. Im trying to access a CheckBox List. Using Smart Blog and adapting how it usually gets those prevalues.
I have the following code:
I belive this section needs changing to access the Property Value Converter?
Unsure how to access the String array in the value? Tried casting it to a String[] but just get null value. Can someone point me in the right direction. The online documents don't outline Checkbox list.
I may have fixed this myself :)
I changed the code to this:
Seems the DataValue returns the comma delimited string i need to split.
Late to the party but for this checkboxlist issue, but for 7.6+ if the EnablePropertyValueConverters option is set to true in the umbracoSetting.config then you can cast a checheckboxlist as an IEnumerable
is working on a reply...