如何在非评论帖中显示主题图

Hey, for metric report purposes, I’m trying to see if there’s a setting or CSS implementation to show the topic-map for all posts (even posts that don’t have comments)?


Above is a screenshot of a post not showing any topic-map

Imgur
Above is an imgur showing the topic-map once it has at least one comment

Any insight is appreciated! Thanks!

2 个赞

I haven’t tried these out, so I may be mistaken, but there are a few ‘summary’ options in the Admin/Other settings that may tweak what you need:

/admin/site_settings/category/uncategorized?filter=Summary

Sorry, I think I had a brainfart and conflated a couple of different things. :slightly_smiling_face:

2 个赞

I had somebody check out the Admin Settings for me and they said they couldn’t find it. I don’t have access :cry:

There are a few workarounds in this topic (variations of ‘add a post’):

2 个赞

There’s not a setting for this, it requires the topic to have at least one reply. Is there a specific reason you want it to show?

3 个赞

I was thinking about that as a last option type of thing. Don’t really want to add a filler comment/post for the sake of keeping things streamlined.

1 个赞

Hey, @awesomerobot
Yes. I am performing weekly metric reports on posts/publications to begin analyzing traffic and engagement with certain topics/teams.

but more specifically, the view count is what you’re after? everything else would show 0:

We’ve had a couple requests for this, so maybe we should work out a mini-topic-map that shows the views in the case where there’s only a single post…

6 个赞

Yes, just the view count. That would help keep the high-priority metrics consistent between all posts.
It would be super awesome if you and your team takes some time to work on something. I’m sure a number of people would appreciate it =)

你好,我想知道现在是否可以查看没有评论的主题视图?

1 个赞

你好,欢迎你 @Salome_renaud :slight_smile:

你可以在主帖列表中看到它们,但我恐怕仍然无法为没有回复的主题生成主题地图。

提醒一下,这在移动设备上是不可能的,所以据我所知,在移动设备上无法查看没有回复的话题的浏览次数。

2 个赞

你好,

现在我看到了这个话题,我想起了我之前看到过关于这个的提交:slightly_smiling_face:

我认为现在应该可以了 :arrow_down_small:

Header

<script type="text/discourse-plugin" version="0.8">
  api.includePostAttributes('topicMap');
</script>


我还添加了一些 CSS 来隐藏没有其他帖子时不需要的统计信息。

Common / CSS

body:not(.archetype-private_message) {
  .topic-post.regular {
    // if last-of-type is the #post_1
    &:last-of-type {
      article#post_1 {
        .topic-map {
          width: max-content;
          nav.buttons {
            display: none;
          }
          ul li {
            // hide all statistics but views
            &:not(.secondary.views) {
              display: none;
            }
          }
          // show views on mobile view
          .secondary.views {
            .mobile-view & {
              display: list-item;
              text-align: center;
            }
          }
        }
      }
    }
  }
}

Desktop (with no reply)

Mobile (with no reply)

When someone reply it changes back to the default.

14 个赞

但如果这些就是你所需要的,并且已经在主题列表中了,为什么还需要进入主题视图来查看这个指标呢?

你甚至可以利用“热门”列表来按给定时间段内的观看次数对主题列表进行排序……

4 个赞

主题 未在主题列表中显示时,我们如何查看一个没有回复且有些旧的主题的视图?

您可以按类别和/或标签筛选主题列表。因为主题更少,所以更容易找到您想要的主题。示例 供您参考。

使用 Experimental topics list filter feature 的新筛选选项,您可以进一步筛选主题列表。例如,您可以筛选只包含一个帖子的主题。
最多 1 个帖子的最新主题

3 个赞

@Moin
非常感谢您向我推荐这条“过滤器”路由。谢谢。

顺便问一下,搜索/过滤“posts-max:-1”和不带减号的“posts-max:1”有什么区别?

1 个赞

非常感谢您,@Don

您提供了一个非常简单、高效且方便的解决方案。它完全符合预期。

@Don 我正在将此代码用作组件,也许它之前可以工作,但在我将其从当前默认主题中删除然后重新添加相同代码(未更改代码中的任何字符)后,它突然停止工作了。

代码/组件:

即使在浏览器中按 Ctrl+F5 后也未显示,您可以在此处看到:

现在有一个 show_topic_map_in_topics_without_replies 设置供您使用

2 个赞