# 有没有办法在用户页面中移除列？

**URL:** <https://meta.discourse.org/t/any-way-to-remove-columns-in-the-users-page/155286>\
**Category:** UX\
**Created:** [2020年六月18日 23:35 UTC](https://meta.discourse.org/t/any-way-to-remove-columns-in-the-users-page/155286 "2020-06-18T23:35:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![b481](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@b481](https://meta.discourse.org/u/b481)\
**Post date:** [2020年六月18日 23:35 UTC](https://meta.discourse.org/t/any-way-to-remove-columns-in-the-users-page/155286/1 "2020-06-18T23:35:55Z")

</div>

我们特别希望从用户页面（[www.example.com/u](http://www.example.com/u) 和 [www.example.com/users）中移除“访问次数”、“已查看”和“已阅读”这几列，但至今尚未找到方法。有人知道这是否可行吗？](http://www.example.com/users%EF%BC%89%E4%B8%AD%E7%A7%BB%E9%99%A4%E2%80%9C%E8%AE%BF%E9%97%AE%E6%AC%A1%E6%95%B0%E2%80%9D%E3%80%81%E2%80%9C%E5%B7%B2%E6%9F%A5%E7%9C%8B%E2%80%9D%E5%92%8C%E2%80%9C%E5%B7%B2%E9%98%85%E8%AF%BB%E2%80%9D%E8%BF%99%E5%87%A0%E5%88%97%EF%BC%8C%E4%BD%86%E8%87%B3%E4%BB%8A%E5%B0%9A%E6%9C%AA%E6%89%BE%E5%88%B0%E6%96%B9%E6%B3%95%E3%80%82%E6%9C%89%E4%BA%BA%E7%9F%A5%E9%81%93%E8%BF%99%E6%98%AF%E5%90%A6%E5%8F%AF%E8%A1%8C%E5%90%97%EF%BC%9F)

---

<div class="post-metadata">

**Author:** ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)\
**Post date:** [2020年六月19日 01:43 UTC](https://meta.discourse.org/t/any-way-to-remove-columns-in-the-users-page/155286/2 "2020-06-19T01:43:55Z")

</div>

如果您只是想从界面中隐藏它，当然可以使用自定义 CSS 来实现。

---

<div class="post-metadata">

**Author:** ![Jonathan5](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jonathan5/32/197134_2.png) [@Jonathan5](https://meta.discourse.org/u/Jonathan5)\
**Post date:** [2020年十月23日 10:04 UTC](https://meta.discourse.org/t/any-way-to-remove-columns-in-the-users-page/155286/3 "2020-10-23T10:04:30Z")

</div>

我有同样的问题。我想移除“收到的点赞”、“给予的点赞”和“访问天数”这几列。

我无法通过 CSS 实现这一点。这些列似乎都是由 class 为“number”的 td 元素组成的，但没有 id。

这可行吗？

我知道最彻底的办法是更改“启用用户目录”的设置。

谢谢。

---

<div class="post-metadata">

**Author:** ![Jonathan5](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jonathan5/32/197134_2.png) [@Jonathan5](https://meta.discourse.org/u/Jonathan5)\
**Post date:** [2020年十月23日 21:14 UTC](https://meta.discourse.org/t/any-way-to-remove-columns-in-the-users-page/155286/5 "2020-10-23T21:14:59Z")

</div>

好的，我们开始。如果 Discourse 更改其用户目录结构，这段代码可能会失效，但在缺乏能唯一标识表格各元素的方法的情况下，这已是我能做到的最佳方案。请将此代码放入自定义主题组件的 CSS 部分。

```css
div.users-directory table th:nth-child(2), 
div.users-directory table th:nth-child(3), 
div.users-directory table th:nth-child(8), 
div.users-directory table td:nth-child(2), 
div.users-directory table td:nth-child(3), 
div.users-directory table td:nth-child(8) {
    display:none;
}

```

我感觉这段代码还有优化空间，但目前它似乎能正常工作，并且看起来不会破坏其他表格。

---

<div class="post-metadata">

**Author:** ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)\
**Post date:** [2020年十月23日 21:37 UTC](https://meta.discourse.org/t/any-way-to-remove-columns-in-the-users-page/155286/6 "2020-10-23T21:37:00Z")

</div>

您想要实现的功能可以通过覆盖现有的页面模板来完成。这里有一个移除列的示例：

> [@Developing Discourse Themes & Theme Components](https://meta.discourse.org/t/developer-s-guide-to-discourse-themes/93648#heading--4-b-2):
>
> Discourse Themes and Theme Components can be used to customize the look, feel and functionality of Discourse’s frontend. This section of the developer guides aims to provide all the reference materials you need to develop simple themes for a single site, right up to complex open-source theme components. This introduction aims to provide a map of all the tools and APIs for theme development. If you prefer a step-by-step tutorial for theme development, jump straight to: Themes vs. Theme Compon…

---

<div class="post-metadata">

**Author:** ![Jonathan5](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jonathan5/32/197134_2.png) [@Jonathan5](https://meta.discourse.org/u/Jonathan5)\
**Post date:** [2020年十月23日 21:45 UTC](https://meta.discourse.org/t/any-way-to-remove-columns-in-the-users-page/155286/7 "2020-10-23T21:45:34Z")

</div>

谢谢。我会查看一下，不过目前大概率会先保留现有设置 🙂

另外，我注意到“所有时间”用户目录页面还有一个第9列，我也希望将其隐藏。
