0

I'm doing my first steps with SharePoint and I don't have any idea how to show the number of comments of each entry of a blog in a different page in a upper level.

I guess I have to use a "Content Query Web Part". I edited ItemStyle.xsl adding the fields I want to add, in order to choose the field in the webpart options using the online editor when I edit the page.

I don't know how to continue. What is the next thing I have to do?

Edit

Let me explain the problem again, because I think it wasn't explain correctly.

I have a Site Web with some subsites blog. In order to show the entries in the top site, I set a custom site content type for the entries with the title, etc. fields. With a Content Query Web Part, I choose the BlogEntries and I use my site content type I set. So in the parent site, I can see the entries. It's different for the comments of each entry, because Number of Comment column is not available (I could see this variable on the blog list of entries).

So, the question is, how can I see the number of comment? I thought to add a column into my Site Content Type, but i wasn't able to calculate or search the correct number of comments.

5

1 Answer 1

1

How you can do this using REST API and jquery

Make a GET request to the following URL

/_api/Web/Lists/getbytitle('Comments')/items?$select=Title,PostTitle/Title&$expand=PostTitle

It will give you response like following

{
    "d": {
        "results": [
            {
                "__metadata": {
                    "id": "3d7e5b5c-51fe-4b97-918b-70fb47a44f85",
                    "uri": "YourBlogSiteUrl/_api/Web/Lists(guid'5cd08a1c-e3b0-4aef-bfe2-d58f9dc65e2b')/Items(1)",
                    "etag": "\"1\"",
                    "type": "SP.Data.CommentsListItem"
                },
                "PostTitle": {
                    "__metadata": {
                        "id": "3ba5d89b-048f-41bc-8b7f-b5ecec73a935",
                        "type": "SP.Data.PostsListItem"
                    },
                    "Title": "First post"
                },
                "Title": "sdfsd"
            },
            {
                "__metadata": {
                    "id": "3eba0473-0923-432b-9379-7207b681feae",
                    "uri": "YourBlogSiteUrl/_api/Web/Lists(guid'5cd08a1c-e3b0-4aef-bfe2-d58f9dc65e2b')/Items(2)",
                    "etag": "\"1\"",
                    "type": "SP.Data.CommentsListItem"
                },
                "PostTitle": {
                    "__metadata": {
                        "id": "6e7b3cdc-ec25-41c6-b6c2-6fe4482e2ae3",
                        "type": "SP.Data.PostsListItem"
                    },
                    "Title": "First post"
                },
                "Title": "sdfds"
            }
        ]
    }
}

Now show your comments using jQuery & HTML.

3
  • Thanks for the help. That it was I was thinking to do but... maybe the perfomance won't be as good as we could expect, wiil it? Is there any other posibility to increase the perfomance? Sep 28, 2015 at 18:02
  • @Daniel976034, I did not get your point Sep 29, 2015 at 16:27
  • Hello again @Atish, I added to the description more information about my issue. What I wanted to say before is about the low perfomance of check of each entry from different Lists. I asked if you know other posibility with more performance. Thank you for your time. Sep 30, 2015 at 12:03

Your Answer

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

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