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:
Bianca Nenciu
2024-05-16 10:45:13 +03:00
committed by GitHub
parent d964709644
commit 77b032c2b5
17 changed files with 252 additions and 65 deletions

View File

@ -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],