How to show empty categories in the discussions categories block?

Hello,

The discussions categories block only shows categories with posts. Empty categories are hidden. How to show all the categories, whether they are empty or not, as it's done with other modules categories?

The same applies with Posts, Ads, Articles & News (from AQB), Files, Glossary, Polls, Photos, Videos categories. Empty ones are hidden. I would like to show them all. SOther modules like Courses, Events, Organizations etc already show empty categories in the categories block.

Thanks

  • 298
  • More
Replies (10)
    • Hello UNA Team. Any help on this?

      • Hello !
        

        You need to add the argument 'show_empty_categories' => true, to the code for the categories block it will lo0ok like:

        array (
         'module' => 'system',
         'method' => 'categories_list',
         'params' => 
         array (
          0 => 'bx_forum_cats',
          1 => 
          array (
           'show_empty' => true,
           'show_empty_categories' => true,
          ),
         ),
         'class' => 'TemplServiceCategory',
        )
        
        • Hi @LeonidS . Thanks for your reply. Where should I aplly the change: injection, raw block? Or should I modify the source code? And the change will be lost when the system updates, right?

          • You may create the service block with this code. And it will not be lost after the upgrade.

            • Thanks. I can see the option of creating a service block here: Studio->Developer->Pages->Discussions->Discussions Home.

              About the code that should be placed in the service block, is it the array code you posted above?

              Also I would like to show empty categories of many other modules. Should I create the service block for each one of them (module by module)? Is there a way to place the code in the head injection to be used globally?

              Thanks

              • 1) Yes, it is a PHP array code, just enter it to the Code field of your service block.

                2) Yes, you need to create similar blocks for every module or edit the currents. Except the Groups-based apps because they have the Categories block with already enabled "show empty categories" parameter.

                • Ok Thank you for the guidance.

                  • Thanks for raising this issue. When you do it as described above, the service block will show a plain list with no Icons (see attached image below). How to get one similar to the one that is already there with discussion?

                    image_transcoder.php?o=sys_images_editor&h=2697&dpx=2&t=1747273617

                    • Good question!

                      • We provided the common method to draw the block with all categories, but the Discussions block Categories is the special block working from the Studio -> Discussions -> Categories area.

                        Login or Join to comment.