I installed SmartBlog v2 and noticed when you click on one of the tags under the Tags Header it throws error if any of the existing posts dont have a tag attached to them. The error is comming from line 37 in the partial macro SmartListPosts.chtml. As a qucik fix i change the line from
where ((IList)result.GetProperty("smartBlogTags").Value.ToString().Split(',')).Contains(Request.QueryString["tag"])
to
where (result.HasValue("smartBlogTags") && ((IList)result.GetProperty("smartBlogTags").Value.ToString().Split(',')).Contains(Request.QueryString["tag"]))
Category search work fine, but author and tag search fails:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 31: {
Line 32: results = (from result in results
Line 33: where (result.HasValue("smartBlogTags") && ((IList<string>)result.GetProperty("tag").Value.ToString().Split(',')).Contains(Request.QueryString["tag"])) Line 34: select result).ToList();
Line 35: }
and:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 39: {
Line 40: results = (from result in results
Line 41: where ((IList<string>)result.GetProperty("smartBlogAuthor").Value.ToString().Split(',')).Contains(Request.QueryString["author"]) || Line 42: (Request.QueryString["author"] == document.GetElementsByTagName("defaultAuthor")[0].InnerText && result.GetProperty("author").Value.ToString().Length == 0)
Line 43:
Now, author is set on all posts, and all posts have at least on tag. It shouldn't be due to the fact that the blog is not in the root, or is that a wrong assumption?
I think the issue for both of these is that the GetProperty is referencing the wrong property.
line 33 says
results = (from result in results
where (result.HasValue("smartBlogTags") && ((IList<string>)result.GetProperty("tag").Value.ToString().Split(',')).Contains(Request.QueryString["tag"]))
select result).ToList();
where is should say
results = (from result in results
where (result.HasValue("smartBlogTags") && ((IList<string>)result.GetProperty("smartBlogTags").Value.ToString().Split(',')).Contains(Request.QueryString["tag"]))
select result).ToList();
tag search bug
Hi,
I installed SmartBlog v2 and noticed when you click on one of the tags under the Tags Header it throws error if any of the existing posts dont have a tag attached to them. The error is comming from line 37 in the partial macro SmartListPosts.chtml. As a qucik fix i change the line from
where ((IList)result.GetProperty("smartBlogTags").Value.ToString().Split(',')).Contains(Request.QueryString["tag"])
to
where (result.HasValue("smartBlogTags") && ((IList)result.GetProperty("smartBlogTags").Value.ToString().Split(',')).Contains(Request.QueryString["tag"]))
Thanks
lj
Hi lj,
Thanks for letting me know, this fix will be in the next version release. :D
Luke
Actually I get an error with this fix...
I installed SmartBlog v 2.0.7 on Umbraco 7.1.4.
Category search work fine, but author and tag search fails:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 31: { Line 32: results = (from result in results Line 33: where (result.HasValue("smartBlogTags") && ((IList<string>)result.GetProperty("tag").Value.ToString().Split(',')).Contains(Request.QueryString["tag"])) Line 34: select result).ToList(); Line 35: }
and:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 39: { Line 40: results = (from result in results Line 41: where ((IList<string>)result.GetProperty("smartBlogAuthor").Value.ToString().Split(',')).Contains(Request.QueryString["author"]) || Line 42: (Request.QueryString["author"] == document.GetElementsByTagName("defaultAuthor")[0].InnerText && result.GetProperty("author").Value.ToString().Length == 0) Line 43:
Now, author is set on all posts, and all posts have at least on tag. It shouldn't be due to the fact that the blog is not in the root, or is that a wrong assumption?
Kind regards,
Bruno
I think the issue for both of these is that the GetProperty is referencing the wrong property.
line 33 says
where is should say
The difference being
is changed to
This fixed mine anyway.
Hi Bruno & Jonathan,
Thank you for taking the time to investigate this issue, I have just updated the projects source code. I'll compile and upload a new version today.
Thanks again, Luke
is working on a reply...