Hey guys, I would like to know if anyone has ever tried to show Views instead of the number of replies in the homepage.
I was able to hide the number of replies using CSS, but I’m having a hard time trying to show the number of Views in that place.
Any ideas?
Thanks!
1 Like
I’m looking for this very feature. Have you found any solution to this? @Tiago_Amaral
Any updates @Discourse ?
2 Likes
Lilly
June 22, 2023, 12:44am
3
i may take a stab at this in next few days if i have time. i am working on a theme component that does something similar.
3 Likes
tshenry
(Taylor)
June 22, 2023, 8:29am
4
I went ahead and added a plugin outlet to make it extra easy:
discourse:main
← discourse:post-count-outlet
opened 12:24AM - 22 Jun 23 UTC
Introduces a new above-latest-topic-list-item-post-count outlet, providing a cle… an way to add other useful elements to the topic-stats section of the latest-topic-list-item template.
One example use case is replacing the post count with a view count as requested in [this Meta topic](https://meta.discourse.org/t/show-views-instead-of-replies/187146):
<img width="568" alt="Screenshot 2023-06-21 at 5 21 31 PM" src="https://github.com/discourse/discourse/assets/22733864/912b77ed-887e-4402-a50d-0079ef61666d">
If you add something like this to the Head section of a theme component, you’ll see it adds the views. You can add additional HTML if needed and style to taste from there
<script type="text/x-handlebars" data-template-name="/connectors/above-latest-topic-list-item-post-count/views-count">
{{topic.views}} views
</script>
2 Likes
Lilly
June 22, 2023, 10:25am
5
oh nice. thank you. @tshenry
1 Like
Lilly
June 24, 2023, 4:18am
6
ok so i put this functionality into a theme component that has settings for controlling all three stats in the topic list of the main category page - total number of views, replies count, and time since last activity.
2 Likes