FEATURE: ability to register custom filters for posts (#12938)

Allow plugins to extend TopicView to filter posts
This commit is contained in:
Krzysztof Kotlarek
2021-05-10 08:57:58 +10:00
committed by GitHub
parent f337d59ed9
commit a4bd1806d9
4 changed files with 67 additions and 0 deletions

View File

@ -208,6 +208,14 @@ class Plugin::Instance
Search.advanced_filter(trigger, &block)
end
# Allows to define TopicView posts filters. Example usage:
# TopicView.advanced_filter do |posts, opts|
# posts.where(wiki: true)
# end
def register_topic_view_posts_filter(trigger, &block)
TopicView.add_custom_filter(trigger, &block)
end
# Allow to eager load additional tables in Search. Useful to avoid N+1 performance problems.
# Example usage:
# register_search_topic_eager_load do |opts|