可点击的话题

:discourse2: Summary Clickable Topic makes the entire area of a topic-list-item clickable, as opposed to just the topic title.
:eyeglasses: Preview Preview on Discourse Theme Creator
:hammer_and_wrench: Repository Link https://github.com/discourse/discourse-clickable-topic
:open_book: New to Discourse Themes? Beginner’s guide to using Discourse Themes

Install this theme component

Features

preview

:discourse2: Hosted by us? Theme components are available to use on our Standard, Business, and Enterprise plans.

Last edited by @JammyDodger 2024-06-11T12:48:31Z

Check documentPerform check on document:
46 个赞

Thank you so much, very needed thing! :heart:

4 个赞

That is a very helpful component! Should be from user experience point of view built into Discourse, but that is my opinion.

Anyways, I’m stuck in trying to make the same logic work for Categories. I wanted to do it with api.modifyClass but seem to miss the crucial part. Can you please help me?

I have this setting for my desktop page:
image

Basically the red box on the left should be clickable:

Or to have a perfect picture what I want to achieve: recreating the Blizzard Forum design, cause I like it a lot:

Appreciate any help here.

While waiting for a response I also found the components page here:

And tried different ideas but it seems my hook is not even available? Or I’m missing something!? :slight_smile:

Glad you like the component!

Thanks for the suggestions :grinning_face_with_smiling_eyes:

At the moment this component is only designed to work for Topics in a topic list.

1 个赞

If you want to experiment and fork this component, you are welcome to do so :+1:

As a starting point to get a category to be clickable, I would suggest looking through the code in this component that does so by modifying the topic-list-item component inside Discourse core.

You could try creating a new file within this same folder which targets one of the many types of category layouts included in our components, making sure to target the same category page style you have selected on your forum.

Some of these are listed in their locations below…

app/assets/javascripts/discourse/app/components/categories-and-latest-topics.js
app/assets/javascripts/discourse/app/components/categories-and-top-topics.js
app/assets/javascripts/discourse/app/components/categories-boxes-topic.js
app/assets/javascripts/discourse/app/components/categories-boxes-with-topics.js
app/assets/javascripts/discourse/app/components/categories-boxes.js
app/assets/javascripts/discourse/app/components/categories-only.js
app/assets/javascripts/discourse/app/components/category-list-item.js

3 个赞

预览不再起作用

2 个赞

我觉得现在应该没问题了。:slightly_smiling_face::+1:

2 个赞

现在已损坏。

我们曾依赖此组件来使“分类 + 最新”视图(在我们的情况下为默认视图)的主题卡片可点击。自今天更新到最新的 3.1.0beta8(现在显示为 3.2.0.beta1-dev)以来,该组件已停止正常工作。

现在光标的活动状态仍然是可点击的,但主题区域不可点击。打开浏览器的控制台会显示一个错误,这可能有助于开发人员识别问题:

未捕获的 TypeError: this.router is undefined

function navigateToTopic(topic, href) {
    if (this.siteSettings.page_loading_indicator !== "slider") {
      // With the slider, it feels nicer for the header to update once the rest of the topic content loads,
      // so skip setting it early.
      this.appEvents.trigger("header:update-topic", topic);
    }
    this.session.set("lastTopicIdViewed", {
      topicId: topic.id,
      historyUuid: this.router.location.getState?.().uuid
    });
    _url.default.routeTo(href || topic.get("url"));
    return false;
  }

抛出错误的行:

historyUuid: this.router.location.getState?.().uuid

这是否与核心中计划/正在进行的 Ember 升级有关?

您好 @kinetiksoft - 我无法在我的端重现此问题。该主题组件似乎与最新版本的 Discourse 配合良好。此处 OP 中的“在主题创建者上预览”链接似乎也能正常工作。

您能否分享一个出现问题的网站链接?也许是与其他主题/插件发生了冲突。

2 个赞

谢谢!我已私信您一个相关社区的链接。不适合在此公开分享。

1 个赞

感谢 @kinetiksoft!看起来问题发生在当主题组件与“分类 + 最新”视图(您已将其配置为主页)一起使用时。

我已提交一个 PR,应该可以解决该问题。

合并后我将在此处发布,然后您需要将论坛更新到最新版本的 Discourse 核心。

3 个赞

谢谢你,大卫!很高兴我们能帮助识别出完美运行组件中的问题。

2 个赞

全部完成 - 因此,下次您更新到最新版本的 Discourse 时,它应该会生效

1 个赞

我们将在本周晚些时候进行更新尝试,我一定会回到这个话题来汇报一切进展情况。再次感谢!

1 个赞

我们确认问题已修复。再次感谢!:heart:

1 个赞

您好,如何修改此组件以支持 Docs 插件?

我正在运行最新的 Discourse 3.4.0.beta2-dev。


我不确定是我对这个主题组件的设置有什么问题,还是其他原因,但卡片上主题的所有正文都无法点击。如果你点击文本末尾的任意一行,你就可以激活卡片并打开主题。

你认为可能是什么原因造成的?

提前感谢你的所有帮助和建议。:slight_smile:

4 个赞

您好,感谢您的 TC,但似乎有一个区域仍然无法点击?