I'm new to both Umbraco and Smart Blog. I have managed to get the tags from an article to display. However, I need them to display as links to a search for other items with the same tag, similar to how the tags on the Smart Blog test page work. Any help would be appreciated.
However I found that the code which handles tags when you click on them (and comments possibly) uses LINQ which falls over if a blog post has no Tags. (you will get the object null ref error)
I changed it to this :-
// Refine posts by tag
if (!String.IsNullOrEmpty(Request.QueryString["tag"]))
{
List<IPublishedContent> tempResults = new List<IPublishedContent>();
//Loop through posts
foreach(var post in colResults)
{
//Check post has tags
if (post.GetPropertyValue<String>("smartBlogTags") != null)
{
//check if any tags match the tag in request
if (post.GetPropertyValue<String>("smartBlogTags").Split(',').Contains(Request.QueryString["tag"]))
{
tempResults.Add(post);
}
}
}
colResults = tempResults;
}
This does not fall over if a post doesn't contain any tags. I think a similar thing may be needed for comments but we don't use them so we commented them out.
Issues creating tags as links
I'm new to both Umbraco and Smart Blog. I have managed to get the tags from an article to display. However, I need them to display as links to a search for other items with the same tag, similar to how the tags on the Smart Blog test page work. Any help would be appreciated.
Hi Brandon,
The Tags that appear are already Links , On clicking of which it displays All articles that have the same Tags.
Can you be more specific on what error you are facing
Swathi
If you call the partial
It will display the tags as links.
However I found that the code which handles tags when you click on them (and comments possibly) uses LINQ which falls over if a blog post has no Tags. (you will get the object null ref error)
I changed it to this :-
This does not fall over if a post doesn't contain any tags. I think a similar thing may be needed for comments but we don't use them so we commented them out.
is working on a reply...