Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
767 views
in Q2A Core by
Assume there many categories in our QAand we want to show the ones with no question posted in them on the side bar. How can we do that
Q2A version: Q2A 1.5.4

2 Answers

0 votes
by
I am also interested in hiding empty categories
+2 votes
by

You may wanna consider creating a pluging since it's not avised to change the core code, especially this function could be override easily.

Find  function qa_category_navigation_sub(){}        in qa-aap-format.php and  change it with this:

    function qa_category_navigation_sub($parentcategories, $parentid, $selecteds, $pathprefix, $showqcount, $pathparams)
/*
    Recursion function used by qa_category_navigation(...) to build hierarchical category menu.
*/
    {
        if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
        
        $navigation=array();
if (!isset($parentid))
            $navigation['all']=array(
                'url' => qa_path_html($pathprefix, $pathparams),
                'label' => qa_lang_html('main/all_categories'),
                'selected' => !count($selecteds),
                'categoryid' => null,
            );
        
        if (isset($parentcategories[$parentid]))
            foreach ($parentcategories[$parentid] as $category)
                $navigation[qa_html($category['tags'])]=array(
                    'url' => qa_path_html($pathprefix.$category['tags'], $pathparams),
                    'label' => $category['qcount']>0 ? qa_html($category['title']) :null,
                    'popup' => qa_html(@$category['content']),
                    'selected' => isset($selecteds[$category['categoryid']]),
                    'note' => $category['qcount'] > 0  ? ('('.qa_html(number_format($category['qcount'])).')') : null,
                    'subnav' => qa_category_navigation_sub($parentcategories, $category['categoryid'], $selecteds, $pathprefix.$category['tags'].'/', $showqcount, $pathparams),
                    'categoryid' => $category['categoryid'],
                );
        
        return $navigation;
    }

That should help you out

by
Best answer :)
...