# 自定义主题过滤器：URL参数未传递到 \`TopicQuery.options\`

**URL:** https://meta.discourse.org/t/custom-topic-filters-url-params-not-reaching-topicquery-options/367291
**Category:** Development
**Created:** [2025年五月22日 21:05 UTC](https://meta.discourse.org/t/custom-topic-filters-url-params-not-reaching-topicquery-options/367291 "2025-05-22T21:05:46Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![SubStrider](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/substrider/32/512604_2.png) [@SubStrider](https://meta.discourse.org/u/SubStrider)
#### Post date: [2025年五月22日 21:05 UTC](https://meta.discourse.org/t/custom-topic-filters-url-params-not-reaching-topicquery-options/367291/1 "2025-05-22T21:05:46Z")

</div>

在使用URL查询参数（例如 `...?market_item_statuses=Available`）构建具有自定义主题列表过滤器（如按价格、位置）的插件时，URL正确更新，但参数没有显示在服务器端的 `topic_query.options` 中。

**设置：**

1. **客户端参数注册（`tecenc-discovery-params.js`）：**

2. **服务器端白名单尝试（`plugin.rb`）：**

3. **服务器端过滤逻辑（`plugin.rb`）：**

**问题（日志）：**

1. 参数白名单失败：

2. 在 `TopicQuery.add_custom_filter` 中，`opts` 缺少我们的自定义参数：  
当URL为 `...?market_item_statuses=Available`时，日志显示：

我们的 `market_item_statuses`（以及其他自定义参数）不存在。

**我们的环境：**

**问题：**

1. 在最新的 Discourse 版本中，确保自定义 URL 查询参数到达 `topic_query.options` 的目前最佳实践是什么？
2. 为什么我们尝试使用 `add_custom_param_handler` 或 `extra_options_whitelist` 时会出现 “Could not find a suitable method” 的警告，操作失败？
3. 是否有其他的参数注册方法可以用于 `TopicQuery`，我们应该考虑使用？

任何帮助将不胜感激！

---

_[View the full topic](https://meta.discourse.org/t/custom-topic-filters-url-params-not-reaching-topicquery-options/367291)._
