Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Brandon Frost 6 posts 26 karma points
    May 19, 2015 @ 21:42
    Brandon Frost
    0

    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.

  • Swathi 87 posts 281 karma points
    May 28, 2015 @ 15:30
    Swathi
    1

    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

  • Thomas Haxley 2 posts 22 karma points
    Mar 07, 2016 @ 11:54
    Thomas Haxley
    0

    If you call the partial

    @Html.Partial("SmartListTags")  
    

    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 :-

    // 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.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies