3

When reading a blog post in SharePoint, I'd like to be able to display a list of other posts that are related based on the category of the existing post. I thought I could just add the post list web part and then connect it to the post on the page and send the category, but that doesn't work. Maybe because in the blog you can select multiple categories. So I'm a bit stuck on how to accomplish this. Anyone have any suggestions?

We are on SharePoint 2010, and I'm using the OOB blog site. One other caveat is that I'm not a developer, so complex coding solutions are not an option. Need to be able to use OOB web parts. Can use script in a CEWP if necessary.

2
  • Hi and welcome to SharePoint.StackExhange Brendan! I think you have asked a good question here, and I believe you'll get an answer soon. If you want to, you can improve your question by adding which SharePoint version you're using, what template your web has, containing your blog. I'm happy to see you here!
    – Benny Skogberg
    Commented Nov 1, 2013 at 18:21
  • 1
    I updated the question with that information. Commented Nov 1, 2013 at 20:39

1 Answer 1

1

You can do it easily.

  1. Create a WCF service to get the related posts based on tags
  2. Create a User Control
  3. Write a c# method to get the tags/category of the loaded post
  4. Send the tags/category as param to the web service
  5. Get the records and update the control using JQuery. Since it is ajax call and it will not impact the performance of the page.
  6. Load the user control in the web part(Visual web part will do the work)

We have done this in our intranet.

Eg code:

function getItems() {
    queryTags = "sharePoint 2013"; // use c# method here
    var test = '{"tag":"' + escapeHTML(queryTags) + '"}';
    $.ajax({
        type: "POST",
        url: "/Services/DataService.svc/GetRelatedArticles",
        data: test,
        processData: false,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (result) {
            var contents = '';
            var jsonOBJ2 = $.parseJSON(result.d);
            $.each(jsonOBJ2, function (i, item) {
                var newsUrl = item.PostUrl;
                contents += "add rows";  
            });
            jQuery('#processing_ctl00_RelatedContent1').html('');
            $('#relatedContent_ctl00_RelatedContent1').html(contents);

        },
        error: function (msg) {
            $("#errorDiv").text(msg);
        }
    });
}

function escapeHTML(str) {
    return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
2
  • Thanks for the response, but I'm not a developer. This is way above my skill level. Is this the only way to accomplish this? Commented Nov 1, 2013 at 20:40
  • Not much idea about how to achieve this using OOB features Commented Nov 2, 2013 at 4:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.