I'm running Umbraco version 7.12.1 and SmartBlog 2.2.1.
In order to get it working I have done some fixes to SmartListTags.cshtml and SmartListCategories.cshtml.
Everything seems to work fine except the SmartBlog Manager. getPropertyValue() and getPost() in smartBlogManagement.asx returns "System.NullReferenceException: 'Object reference not set to an instance of an object.'"
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using System.Web.Mvc.Html;
@using Umbraco.Web;
@using Umbraco.Core.Models;
@{
// 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");
// Create the tag dictionary
Dictionary<String, Int32> colTagList = 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.Where(x => !String.IsNullOrEmpty(x.GetPropertyValue<String>("smartBlogTags"))))
foreach (IPublishedContent objPost in colPosts.Where(x => !String.IsNullOrEmpty(x.GetPropertyValue<String>("smartBlogTags"))))
{
foreach (String strTag in (String[])objPost.GetPropertyValue("smartBlogTags"))
{
if (!String.IsNullOrEmpty(strTag))
{
if (colTagList.ContainsKey(strTag))
{
colTagList[strTag]++;
}
else
{
colTagList.Add(strTag, 1);
}
}
}
}
<span class="smartSubTitle">Tags</span><br />
// Loop through the tag dictionary showing most used first
<div class="smartRightLowSectionContainer">
@foreach (KeyValuePair<String, Int32> objTag in colTagList.OrderByDescending(x => x.Value))
{
//Deal with the tag
<a class="smartTag [email protected]" href="@Umbraco.NiceUrl(objBlogRoot.Id)[email protected]">
@objTag.Key
</a><span style="color: #666;"> (@objTag.Value)</span><br />
}
</div>
}
SmartListCategories.cshtml
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using System.Web.Mvc.Html;
@using Umbraco.Web;
@{
// 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");
// 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)
{
foreach (var strCategory in objPost.GetPropertyValue<IEnumerable<string>>("smartBlogCategory"))
{
if (colCategories.ContainsKey(strCategory))
{
colCategories[strCategory]++;
}
else
{
colCategories.Add(strCategory, 1);
}
}
}
<span class="smartSubTitle smartTopBorder">Categories</span><br />
// Loop through the tag dictionary
foreach (KeyValuePair<string, int> objCategory in colCategories)
{
//Deal with the tag
<a class="smartCategory" href="@Umbraco.NiceUrl(objBlogRoot.Id)[email protected]">@objCategory.Key</a><br />
}
}
I ran into this too..
Seems to be that it's an issue with dashboard get results returns unpublished nodes.
However the getPropertyValue uses the IpublishedContent cache, so only published nodes.
Hence an error if unpublished node is in the result set.
SmartBlog on Umbraco 7.12.1
Hi,
I'm running Umbraco version 7.12.1 and SmartBlog 2.2.1.
In order to get it working I have done some fixes to SmartListTags.cshtml and SmartListCategories.cshtml.
Everything seems to work fine except the SmartBlog Manager. getPropertyValue() and getPost() in smartBlogManagement.asx returns "System.NullReferenceException: 'Object reference not set to an instance of an object.'"
smartBlogManagement.asx
Fixes:
SmartListTags.cshtml
SmartListCategories.cshtml
Hi im experiencing the same issue. I've copied your code but it hasn't worked for me any other ideas?
Thanks
I ran into this too.. Seems to be that it's an issue with dashboard get results returns unpublished nodes. However the getPropertyValue uses the IpublishedContent cache, so only published nodes. Hence an error if unpublished node is in the result set.
is working on a reply...