How do I get the number of posts on a particular topic?
RéponduI am developing the Help Centre in the following way.
On the home page, I have each community topic displaying as follows:
The text is from the topic description and there is also a follower counter.
I am trying to add the following:
Update: I have written the JavaScript function correctly. In case anyone else finds it useful, here it is:
$.getJSON('/api/v2/community/topics/{id}/posts.json', function(data){
-
Hi Robbie,
I'm not technical so my help is limited but wanted to share what we have in case it of assistance to you.
We have this same concept on our home page but we call them "replies" instead of post.
This is the code I see on the home_page.hbs (based on the Copenhagen theme) for this:
<a :href="post.html_url" class="communitysections-links">{[{post.title}]}</a>
<p class="votes-comments-follows"><span class="communitysections-comments">{[{post.comment_count}]} Replies</span></p>I don't see anything in our script.js file around replies so from what I can tell, it's all handled in the home_page.hbs.
Hopefully that is some kind of help!
Thanks,
Maggie
-
Thanks so much for sharing your solution, Robbie Carew. Do you mind if I move it over to the User Tips & Tricks topic?
-
That is more than fine with me Nicole :)
Vous devez vous connecter pour laisser un commentaire.
3 Commentaires