# 覆盖特定页面的 topic-list-item.hbr 模板

**URL:** https://meta.discourse.org/t/override-topic-list-item-hbr-template-for-specific-page/161039
**Category:** Development
**Created:** [2020年八月16日 14:28 UTC](https://meta.discourse.org/t/override-topic-list-item-hbr-template-for-specific-page/161039 "2020-08-16T14:28:42Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Varhall](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/varhall/32/174181_2.png) [@Varhall](https://meta.discourse.org/u/Varhall)
#### Post date: [2020年八月16日 14:28 UTC](https://meta.discourse.org/t/override-topic-list-item-hbr-template-for-specific-page/161039/1 "2020-08-16T14:28:42Z")

</div>

大家好！

在我的自定义主题中，我重写了 `topic-list-item.hbr` 模板，但这影响了相关主题、消息等。我该如何仅针对主题、分类和标签的主列表重写此模板？

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/6/c626ff9c69bd40f5c175848bc7450ea899a62dca.png)

这样的主题列表破坏了消息列表的布局，看起来不太美观，我希望在那里保留旧的列表。

 ![image](https://global.discourse-cdn.com/meta/original/3X/0/c/0cf0a5d13b39270a98913e6fbc304eee69445df0.png)

---

<div class="post-metadata">

### Author: ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)
#### Post date: [2020年八月16日 14:38 UTC](https://meta.discourse.org/t/override-topic-list-item-hbr-template-for-specific-page/161039/2 "2020-08-16T14:38:02Z")

</div>

这篇指南可能会有所帮助：slight\_smile

> **[Pavilion](https://pavilion.tech/)**
>
> Pavilion is the leading Discourse consultancy.

我意识到你需要使用的条件并不简单。

---

<div class="post-metadata">

### Author: ![Varhall](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/varhall/32/174181_2.png) [@Varhall](https://meta.discourse.org/u/Varhall)
#### Post date: [2020年八月16日 14:49 UTC](https://meta.discourse.org/t/override-topic-list-item-hbr-template-for-specific-page/161039/3 "2020-08-16T14:49:11Z")

</div>

我不太明白，能给我们讲讲吗？或者关于这一点是否有更多信息？

---

<div class="post-metadata">

### Author: ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)
#### Post date: [2020年八月16日 15:00 UTC](https://meta.discourse.org/t/override-topic-list-item-hbr-template-for-specific-page/161039/4 "2020-08-16T15:00:38Z")

</div>

正如我所说，这并非易事。但了解其他开发者或 Discourse 团队是否有兴趣以更简单的方式实现这一点，将非常有趣。

---

<div class="post-metadata">

### Author: ![Varhall](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/varhall/32/174181_2.png) [@Varhall](https://meta.discourse.org/u/Varhall)
#### Post date: [2020年八月16日 15:03 UTC](https://meta.discourse.org/t/override-topic-list-item-hbr-template-for-specific-page/161039/5 "2020-08-16T15:03:00Z")

</div>

以下是相关信息

> [@Override template only on specific page](https://meta.discourse.org/t/override-template-only-on-specific-page/132288/2):
>
> Just to clarify this bit first This is not correct, you don’t lose your changes when you update if they’re made in a theme. They persist. The only way you lose your changes is if you directly edit the files on your server, which you obviously shouldn’t do. Now, there is a certain amount of risk involved in overriding templates in that an update in core might mean that your changes are not compatible anymore and would need to be updated. If you’re fine with that risk then you can technically a…
