diff --git a/Kernel/Config/Files/XML/FAQ.xml b/Kernel/Config/Files/XML/FAQ.xml
index 820da8c..ec6b208 100644
--- a/Kernel/Config/Files/XML/FAQ.xml
+++ b/Kernel/Config/Files/XML/FAQ.xml
@@ -617,6 +617,13 @@ Your OTOBO Notification Master
- 50
+
+ Hide categories in the FAQ Explorer that have no visible articles for the customer.
+ Frontend::Customer::View::FAQExplorer
+
+ - 0
+
+
Default value for the Action parameter for the public frontend. The Action parameter is used in the scripts of the system.
Frontend::Public
diff --git a/Kernel/Language/de_FAQ.pm b/Kernel/Language/de_FAQ.pm
index 3f681f4..0c58fa5 100644
--- a/Kernel/Language/de_FAQ.pm
+++ b/Kernel/Language/de_FAQ.pm
@@ -457,6 +457,8 @@ sub Data {
'';
$Self->{Translation}->{'Maximum size of the titles in a FAQ article to be shown in the FAQ Explorer in the public interface.'} =
'';
+ $Self->{Translation}->{'Hide categories in the FAQ Explorer that have no visible articles for the customer.'} =
+ 'Kategorien im FAQ-Explorer ausblenden, die keine sichtbaren Artikel für den Kunden haben.';
$Self->{Translation}->{'Maximum size of the titles in a FAQ article to be shown in the FAQ Search in the agent interface.'} =
'';
$Self->{Translation}->{'Maximum size of the titles in a FAQ article to be shown in the FAQ Search in the customer interface.'} =
diff --git a/Kernel/Language/en_GB_FAQ.pm b/Kernel/Language/en_GB_FAQ.pm
index c854d0d..b2aaa00 100644
--- a/Kernel/Language/en_GB_FAQ.pm
+++ b/Kernel/Language/en_GB_FAQ.pm
@@ -457,6 +457,8 @@ sub Data {
'';
$Self->{Translation}->{'Maximum size of the titles in a FAQ article to be shown in the FAQ Explorer in the public interface.'} =
'';
+ $Self->{Translation}->{'Hide categories in the FAQ Explorer that have no visible articles for the customer.'} =
+ '';
$Self->{Translation}->{'Maximum size of the titles in a FAQ article to be shown in the FAQ Search in the agent interface.'} =
'';
$Self->{Translation}->{'Maximum size of the titles in a FAQ article to be shown in the FAQ Search in the customer interface.'} =
diff --git a/Kernel/Modules/CustomerFAQExplorer.pm b/Kernel/Modules/CustomerFAQExplorer.pm
index 437389f..b0cf313 100644
--- a/Kernel/Modules/CustomerFAQExplorer.pm
+++ b/Kernel/Modules/CustomerFAQExplorer.pm
@@ -192,6 +192,8 @@ sub Run {
UserID => $Self->{UserID},
);
+ my $HideEmptyCategories = $Config->{HideEmptyCategories} // 0;
+
# check if there are subcategories
if ( $CategoryIDsRef && ref $CategoryIDsRef eq 'ARRAY' && @{$CategoryIDsRef} ) {
@@ -205,7 +207,14 @@ sub Run {
Data => {},
);
+ # get default interface settings
+ my $Interface = $FAQObject->StateTypeGet(
+ Name => 'external',
+ UserID => $Self->{UserID},
+ );
+
# show data for each subcategory
+ CATEGORY:
for my $SubCategoryID ( @{$CategoryIDsRef} ) {
my %SubCategoryData = $FAQObject->CategoryGet(
@@ -220,13 +229,33 @@ sub Run {
);
# get the number of FAQ articles in this category
- $SubCategoryData{ArticleCount} = $FAQObject->FAQCount(
- CategoryIDs => [$SubCategoryID],
- ItemStates => $InterfaceStates,
- OnlyApproved => 1,
- Valid => 1,
- UserID => $Self->{UserID},
- );
+ # if HideEmptyCategories is enabled, only count visible articles for this customer
+ if ($HideEmptyCategories) {
+ my @VisibleItemIDs = $FAQObject->FAQSearch(
+ CategoryIDs => [$SubCategoryID],
+ States => $InterfaceStates,
+ Interface => $Interface,
+ Approved => 1,
+ ValidIDs => [1],
+ Limit => 1,
+ UserID => $Self->{UserID},
+ );
+ $SubCategoryData{ArticleCount} = scalar @VisibleItemIDs;
+ }
+ else {
+ $SubCategoryData{ArticleCount} = $FAQObject->FAQCount(
+ CategoryIDs => [$SubCategoryID],
+ ItemStates => $InterfaceStates,
+ OnlyApproved => 1,
+ Valid => 1,
+ UserID => $Self->{UserID},
+ );
+ }
+
+ # skip category if it has no visible articles and HideEmptyCategories is enabled
+ if ( $HideEmptyCategories && !$SubCategoryData{ArticleCount} && !$SubCategoryData{SubCategoryCount} ) {
+ next CATEGORY;
+ }
# output the category data
$LayoutObject->Block(