mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FEATURE: Filter with CategoryDrop on category page (#26689)
Using the CategoryDrop on the categories page redirected the user to the "latest topics" page with topics only from that category. With these changes, selecting a category will take the user to a "subcategories page" where only the subcategories of the selected property will be displayed.
This commit is contained in:
@ -34,8 +34,12 @@ class CategoriesController < ApplicationController
|
||||
@description = SiteSetting.site_description
|
||||
|
||||
parent_category =
|
||||
Category.find_by_slug(params[:parent_category_id]) ||
|
||||
Category.find_by(id: params[:parent_category_id].to_i)
|
||||
if params[:parent_category_id].present?
|
||||
Category.find_by_slug(params[:parent_category_id]) ||
|
||||
Category.find_by(id: params[:parent_category_id].to_i)
|
||||
elsif params[:category_slug_path_with_id].present?
|
||||
Category.find_by_slug_path_with_id(params[:category_slug_path_with_id])
|
||||
end
|
||||
|
||||
include_subcategories =
|
||||
SiteSetting.desktop_category_page_style == "subcategories_with_featured_topics" ||
|
||||
@ -43,7 +47,7 @@ class CategoriesController < ApplicationController
|
||||
|
||||
category_options = {
|
||||
is_homepage: current_homepage == "categories",
|
||||
parent_category_id: params[:parent_category_id],
|
||||
parent_category_id: parent_category&.id,
|
||||
include_topics: include_topics(parent_category),
|
||||
include_subcategories: include_subcategories,
|
||||
tag: params[:tag],
|
||||
|
Reference in New Issue
Block a user