mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
New site setting: limit_suggested_to_category
- ensures suggested
topics belong to the same category as the current topic and doesn't mix in other categories.
This commit is contained in:
parent
091452e211
commit
5bedc56387
3 changed files with 11 additions and 2 deletions
|
@ -765,6 +765,7 @@ en:
|
|||
max_private_messages_per_day: "The maximum amount of private messages users can create per day"
|
||||
|
||||
suggested_topics: "Number of suggested topics shown at the bottom of a topic"
|
||||
limit_suggested_to_category: "Only show topics from the current category in suggested topics"
|
||||
|
||||
clean_up_uploads: "Remove orphaned uploads to prevent illegal hosting. WARNING: you might want to make a backup of your /uploads directory before enabled this setting."
|
||||
clean_orphan_uploads_grace_period_hours: "Grace period (in hours) before an orphan upload is removed."
|
||||
|
|
|
@ -34,6 +34,9 @@ basic:
|
|||
suggested_topics:
|
||||
client: true
|
||||
default: 5
|
||||
limit_suggested_to_category:
|
||||
client: false
|
||||
default: false
|
||||
default_external_links_in_new_tab: false
|
||||
track_external_right_clicks:
|
||||
client: true
|
||||
|
|
|
@ -20,8 +20,13 @@ class SuggestedTopicsBuilder
|
|||
# Only add results if we don't have those topic ids already
|
||||
results = results.where('topics.id NOT IN (?)', @excluded_topic_ids)
|
||||
.where(visible: true)
|
||||
.to_a
|
||||
.reject { |topic| @category_topic_ids.include?(topic.id) }
|
||||
|
||||
# If limit suggested to category is enabled, restrict to that category
|
||||
if @category_id && SiteSetting.limit_suggested_to_category?
|
||||
results = results.where(category_id: @category_id)
|
||||
end
|
||||
|
||||
results = results.to_a.reject { |topic| @category_topic_ids.include?(topic.id) }
|
||||
|
||||
unless results.empty?
|
||||
# Keep track of the ids we've added
|
||||
|
|
Loading…
Reference in a new issue