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
<td><%# getPropertyValue(Convert.ToInt32(Eval("id")), "smartBlogName")%></td>
<td><%# getPropertyValue(Convert.ToInt32(Eval("id")), "smartBlogComment")%></td>
<<td><%# getPost(Convert.ToInt32(Eval("id"))).GetProperty("smartBlogTitle").Value %></td>
Fixes:
SmartListTags.cshtml
@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 tag-@objTag.Value" href="@Umbraco.NiceUrl(objBlogRoot.Id)?tag=@objTag.Key">
@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)?category=@objCategory.Key">@objCategory.Key</a><br />
}
}