在主题列表中显示主题作者

Hello!

I would like to change the topic list to only display the topic’s author instead of a list of frequent posters in a topic.

Would there be an easy way to accomplish this?

EDIT: Here’s a more complete solution I threw together that you can download as a theme component:

8 个赞

@tshenry,太棒了!我正在寻找类似的解决方案,但我想显示发帖人的用户名而不是他们的头像。

我们可以在哪里查看您组件的仓库?

啊!我确实疏忽了,没有提供下载或查看代码的方式!这只是一段 CSS 代码。等我有空时,我会把它打包成一个完整的主题组件并发布到 GitHub 上。

// 隐藏除主题作者外的所有发帖者
.topic-list .posters {
    width: 75px;
    text-align: center;
    
    // 仅显示第一个发帖者
    a:not(:first-of-type) {
        display: none;
    }
    // 移除偏移和装饰
    a:first-child .avatar.latest:not(.single) {
        position: static;
        box-shadow: none;
        border: 0;
    }
    // 居中对齐的调整
    & > a {
        float: none;
        margin-right: 0;
    }
}

// 确保在较小宽度下显示正确的用户
@media screen and (max-width: 850px) {
    .topic-list td.posters {
        // 确保显示第一个发帖者
        a:not(.latest) {
            display: block;
        }
        // 隐藏其他所有内容
        a:not(:first-of-type) {
            display: none;
        }
    }
}

您想要实现的效果可能更接近以下内容:

4 个赞

这太棒了,谢谢!

移动端 CSS 代码似乎不起作用。Discourse 最近是否更改了移动端帖子作者的组织方式?有什么修复建议吗?

谢谢!

上述 CSS 从未针对移动端设计,但我认为这大概就是你想要的?

1 个赞

是的!我无法像使用你的 CSS 代码那样,通过 CSS 在移动主题中将仅限 OP 的布局限制在特定类别。你有什么建议能帮助我在移动设备上实现这一功能吗?(抱歉,我是 Ember.js 的新手 :/)

不幸的是,仅通过类别进行筛选对于该移动端组件来说是一个相当重大的改动,因为仅凭 Handlebars 文件无法检查类别。你可以尝试以下几种方法:

  • Dev 主题下发帖讨论,看看是否有开发人员能提供一些指导
  • 浏览现有涉及类别的主题组件的代码,寻找灵感或思路
  • Marketplace 发布需求,付费请人帮你实现该功能
2 个赞