mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 13:51:09 +08:00
DEV: add support for adding custom status filter
Those can be used in the /filter routes.
This commit is contained in:
@ -236,6 +236,14 @@ class Plugin::Instance
|
||||
DiscoursePluginRegistry.register_editable_group_custom_field(field, self)
|
||||
end
|
||||
|
||||
# Allows to define custom "status:" filter. Example usage:
|
||||
# register_custom_filter_by_status("foobar") do |scope|
|
||||
# scope.where("word_count = 42")
|
||||
# end
|
||||
def register_custom_filter_by_status(status, &block)
|
||||
TopicsFilter.add_filter_by_status(status, &block)
|
||||
end
|
||||
|
||||
# Allows to define custom search order. Example usage:
|
||||
# Search.advanced_order(:chars) do |posts|
|
||||
# posts.reorder("(SELECT LENGTH(raw) FROM posts WHERE posts.topic_id = subquery.topic_id) DESC")
|
||||
|
Reference in New Issue
Block a user