主题列表侧边栏

:information_source: 原名“Discourse 类别侧边栏”——鉴于该主题组件现已同时支持类别和标签,其名称已更新为 主题列表侧边栏

:discourse2: 摘要 主题列表侧边栏 选取一个主题,并将其作为类别或标签的主题列表的侧边栏应用。
:eyeglasses: 预览 在 Discourse 主题创建器中预览
:hammer_and_wrench: 仓库链接 https://github.com/discourse/discourse-topic-list-sidebars
:open_book: Discourse 主题新手? Discourse 主题使用入门指南

安装此主题组件

功能

该主题组件选取一个主题,并将其作为类别或标签的主题列表的侧边栏应用。这些侧边栏仅在浏览器宽度为 767px 或更宽时可见(大多数平板电脑和显示器)。

我可以利用此主题组件做什么?

  • 选择一个主题并将其内容显示为类别或标签的侧边栏。

  • 通过在设置中将类别名称设为 all,将侧边栏设置显示在 /latest、/new、/unread 和 /top 页面上。

  • 选择侧边栏显示在主题列表的左侧或右侧。

  • 默认情况下,类别的侧边栏也会显示在其所有子类别中,除非子类别已定义了自己的侧边栏(您可以通过取消勾选 继承父级侧边栏 设置来禁用此功能)。

如何配置?

选择您的类别和标签,并添加您希望用于填充侧边栏内容的主题 ID(例如 example.com/t/example-topic/57

我建议在各自的类别/标签中创建侧边栏主题,关闭该主题以防止回复,并将其取消列出(这样它就不会出现在主题列表中)。

请注意,您不能将私有类别中的主题用作公共类别的侧边栏(技术上可以,但没有权限访问该私有主题的用户只会看到一个空侧边栏!)。

设置

名称 描述
sidebars 添加和删除侧边栏
sidebar side 选择左侧或右侧
inherit parent sidebar 如果勾选,子类别将继承其父类别的侧边栏(除非子类别已分配了自己的侧边栏)。

如果未勾选,子类别仅在指定了侧边栏时才会显示。
stick on scroll 如果勾选,侧边栏在滚动时将保持固定位置

开发者须知

每个类别侧边栏都包裹在一个包含类别 slug 的类中,因此对于 staff 类别,该类为 .category-sidebar-staff。您可以使用这些类来为各个侧边栏设置样式。

带有侧边栏的页面上的 body 标签也会添加一个类,因此您可以使用 body.custom-sidebar 为所有带有侧边栏的页面应用样式。

致谢

:heart: 特别感谢 @xrav3nz 为此组件的实现奠定了坚实的基础!


:discourse2: 由我们托管? 主题组件可在我们的标准版、商业版和企业版计划中使用。

59 个赞

Trying to figure out how to make this work with tags as well. (we use tags heavily rather than having tons of categories.)

It looks like it may be about replacing controller:navigation/category with whatever the equivalent for tags is but not sure.

2 个赞

我刚快速看了一下,标签确实可以实现这个功能……

我明天可能会继续完善,并将其独立为一个单独的仓库。

没错,这正是核心所在——以下代码对标签似乎有效:

const controller = container.lookup("controller:tags-show");
const tag = controller.get("tag");

更新:我已经发布了一个主题组件,Discourse Tag Sidebars

10 个赞

Since I am using the header submenu plugin, A part of the text is covered by my header bar. It would be great if it was possible to add extra margin/offset or whatever it’s called for the case when additional elements before the header are covering the sidebar’s content.

Also: is there any way to keep the category drop down menu above the sticky sidebar’s content? that would make it easy for users to jump between categories quickly.

altogether I think the category sidebar is a great plugin and has huge potential to add useful information to the forum structure!

Another great plug-in Kris, thanks!

I have a few questions/suggestions that I hope you can help with…

1 - Is it possible to make this so that when a user browses the forum, going from page to page the sidebar always checks for the latest version of the post that it contains? At the moment I think the content of the sidebar only updates on a page refresh? Unfortunately content that rarely changes begins to appear stale to users (particularly active users) and so I’d like to update the topic associated with the sidebar frequently if I can. (Similarly, if the ID of the topic in the options for that page is changed, it would pick it up on the next page-view). I’m quite happy for the additional load per page/view but if you’re worried others may not be perhaps you could add a “cache post contents” option which would make it work like it does now.

2 - Is it possible to associate/pick up content from more than one topic per sidebar please? So for example on the Latests page you might want the content from topics 33,55 (and in that order). This would be great to allow different content per page while also include common info/links that you might want to appear at the bottom of every sidebar.

3 - Is it possible to expand the plugin so it can be used site-wide please? At the moment I think it can only be used on certain pages? Ideally I’d like to use this across the whole forum on all main sections/pages. (Perhaps your tags sidebar plugin could be used in conjunction with this for finer control - eg for individual tags and/or Topics - I think both combined could become a very power sidebar package!!)

4 - Is it possible to add a sidebar width option as well as a configurable cut-off/display-none point please? This isn’t a biggie as it can be done via css changes but think it would be nice to have in the options.

5 - Last but not least… could you get polls to work please? I think allowing users to vote in polls right out of the sidebar would be awesome!!! I find dynamic content like this in sidebars can make them interesting to users, and so less likely that they’ll automatically ignore them.

I think with all the above this plugin would make a very good candidate to be included in core or an official DC plugin - imo it could help people put an individual stamp on their forums and I’m sure people would use them in fun and interesting ways! :smiley:

Hello,

Great component. Is it possible to have such sidebar for each topic under a specific category?

Thanks.

访问子类别的语法是什么?我目前尝试过以下方法:

category/subcategory,123
subcategory,123
category-subcategory,123

这些似乎都不起作用。不过,主类别是可以显示的。

1 个赞

嗯,有人吗?请帮帮忙……给出一个答案应该没那么难吧……

看起来出现了一个回归问题,在某些情况下子分类无法正常工作,其语法应与分类保持一致:subcategory, 123

我已对主题进行了重构,因此如果您更新主题,子分类将按预期正常工作!

6 个赞

这确实解决了问题:完美!
非常感谢,正好赶上我们的盛大开幕。

1 个赞

很棒的插件!

这个插件是否也支持群组?为群组设置侧边栏将非常有助于提供群组信息。

有人能指引我如何获取群组参数(让组件知道你正处于某个群组中),以便我尝试自己创建一个 PR 吗?

@hyphalos 我创建了一个群组小部件,可以添加到布局插件的侧边栏中。

也许我为它编写的代码可以帮助您编写您的 PR:

或者,您也可以使用布局插件和小部件本身。

2 个赞

虽然要求有点大胆,因为它被称为“侧边栏”,但还是想问一下:是否有可能添加一个选项,将内容始终放在主题列表的“上方”,而不是旁边?

我们使用 Discourse 作为社交内联网,对于某些类别,我们需要一个易于维护的区域来放置链接、人员列表等。——这种机制对此会很棒,但侧边栏的空间太小了。
CSS 技巧也欢迎。

我已经尝试过分类横幅,但它们仅限于第一段,所以这不是一个选项。

此致,
Ralf
(柏林州立图书馆)

关于这个TC呢?

我认为你仍然会被第一个段落困住。但这可能会被改变。

嗨 Kris,这相当不错。

我想知道这是否可以修改,或者是否有一个选项可以将其从侧边栏移到网站标题下方的顶部栏,或者只是移到类别徽标下方?

或者,如果我可以获得有关添加自定义 CSS 来移动它的指导,并且让它在移动设备上显示为顶部,它是否是一个固定的栏? 锚定在主网站栏正下方?

我可能误解了这个主题组件的工作方式,但它是否可以用来将主题列表显示在左侧,点击列表中的某个主题,然后在右侧显示帖子(并保持主题列表固定在左侧)?我不需要看到分类。它看起来会像 Flarum。

1 个赞

不,此组件的作用是获取主题的内容,并使用它来填充特定类别的列表的主题边栏。导航到主题时,它不可见。

好的,谢谢!

大家好!我刚刚对这个组件进行了一次重大更新,它做了几件事:FEATURE: include tag sidebars, migrate to objects setting by awesomerobot · Pull Request #22 · discourse/discourse-topic-list-sidebars · GitHub

  • 将列表样式设置迁移到对象设置。这意味着:

现有设置在更新时应自动迁移……除非您的 slug 与类别名称不同,那么您需要手动更新设置。

例如,site-feedback 将正确迁移到 Site Feedback,但没有方法可以迁移与名称不匹配的 slug(例如,Site Feedback 的 slug 是 hamburgers 而不是 site-feedback)。

我可能会更改此主题组件的名称,并弃用标签侧边栏以反映新情况。

5 个赞

这会自动迁移标签设置吗?

有了新的设置,同一个标签在不同的分类中可以有不同的侧边栏吗?冲突如何解决?

2 个赞