# 显示浏览量而非回复

**URL:** <https://meta.discourse.org/t/show-views-instead-of-replies/187146>\
**Category:** Development\
**Created:** [2021年四月16日 21:16 UTC](https://meta.discourse.org/t/show-views-instead-of-replies/187146 "2021-04-16T21:16:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tiago\_Amaral](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tiago_amaral/32/207734_2.png) [@Tiago\_Amaral](https://meta.discourse.org/u/Tiago_Amaral)\
**Post date:** [2021年四月16日 21:16 UTC](https://meta.discourse.org/t/show-views-instead-of-replies/187146/1 "2021-04-16T21:16:18Z")

</div>

大家好，我想请问是否有人尝试过在首页显示浏览量，而不是回复数量。

 ![Mockup](https://global.discourse-cdn.com/meta/original/3X/f/4/f44daa5cc1b589821d8f293b14488409d27c3359.png)

我能够通过 CSS 隐藏回复数量，但很难在该位置显示浏览量。

有什么想法吗？🙂

谢谢！

---

<div class="post-metadata">

**Author:** ![devrelkyle](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/devrelkyle/32/267950_2.png) [@devrelkyle](https://meta.discourse.org/u/devrelkyle)\
**Post date:** [2023年六月21日 20:16 UTC](https://meta.discourse.org/t/show-views-instead-of-replies/187146/2 "2023-06-21T20:16:03Z")

</div>

我正在寻找这个功能。你找到什么解决方案了吗？@Tiago_Amaral

有什么更新吗@Discourse？

---

<div class="post-metadata">

**Author:** ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)\
**Post date:** [2023年六月22日 00:44 UTC](https://meta.discourse.org/t/show-views-instead-of-replies/187146/3 "2023-06-22T00:44:32Z")

</div>

如果我未来几天有时间，我可能会尝试一下。我正在开发一个功能类似的主题组件。

---

<div class="post-metadata">

**Author:** ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)\
**Post date:** [2023年六月22日 08:29 UTC](https://meta.discourse.org/t/show-views-instead-of-replies/187146/4 "2023-06-22T08:29:23Z")

</div>

我添加了一个插件出口，使其更加容易：

> <https://github.com/discourse/discourse/pull/22238>
>
> 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"\>

如果您将类似这样的内容添加到主题组件的 Head 部分，您会看到它添加了视图。您可以根据需要添加其他 HTML，然后进行样式设置 🙂

```xml
<script type="text/x-handlebars" data-template-name="/connectors/above-latest-topic-list-item-post-count/views-count">
  {{topic.views}} views
</script>

```

---

<div class="post-metadata">

**Author:** ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)\
**Post date:** [2023年六月22日 10:25 UTC](https://meta.discourse.org/t/show-views-instead-of-replies/187146/5 "2023-06-22T10:25:47Z")

</div>

太好了。谢谢你。@tshenry 🙂

---

<div class="post-metadata">

**Author:** ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)\
**Post date:** [2023年六月24日 04:18 UTC](https://meta.discourse.org/t/show-views-instead-of-replies/187146/6 "2023-06-24T04:18:25Z")

</div>

好的，我将此功能放入了一个主题组件中，该组件具有用于控制主类别页面主题列表中所有三个统计信息的设置——查看总数、回复数和上次活动以来的时间。

> [@Topic List Stats](https://meta.discourse.org/t/topic-list-stats/269488):
>
> information_sourceSummary Provides controls for showing category and topic stats on category homepage and topic list filter pageshammer_and_wrenchRepository [https://github.com/Lillinator/topic-list-stats](https://github.com/Lillinator/topic-list-stats)questionInstall Guide [How to install a theme or theme component](https://meta.discourse.org/t/how-do-i-install-a-theme-or-theme-component/63682)open_bookNew to Discourse Themes? [Beginner’s guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966) Install this theme component This simple theme component allows for showing and hiding of the topic list statistics i…
