Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
6.0k views
in Q2A Core by
edited by

How can I get the Unanswered, Hot, Questions, etc. links on the top of the page to display only the corresponding questions in the current category? Typically I want the top-level category, in cases I have multiple sub-categories and are viewing a deeper category level at that moment (but that might be category dependent).

Effectively, I have multiple q2a forums on the same server, separated by category. And when in one of the fora/main-categories, I an not interested in the other ones. So I only want to see the related questions in that area.

I could not find a setting, nor a plugin for that.


Example: when I have currently selected a certain category, (let's say, the URL is http://my_qa_forum.com/questions/testing)  and are viewing that category's questions, I would like to have the links in the menu point to the selections corresponding to that category. Therefore, the URLs of the link "All Activity" should be http://my_qa_forum.com/activity/testing, that of "Questions" should be http://my_qa_forum.com/questions/testing, and "Unanswered" should link to http://my_qa_forum.com/unanswered/testing. The same for "Hot!" or any other applicable links.

The organization of the site is simply as it is out of the box. Only a number of categories have been added, and the topics are not having much overlap, so browsing one topic (= category) means typically we are not interested in hot questions on another topic, and therefore only the hot questions of that topic's category should be shown.

by
Configuration diagram of the sites is necessary. And also, you need to explain your wish more concretely. It will become clearer with screen captures.
by
Thank. I edited the original question.
But what do you mean by 'configuration diagram'? The organization of the site is simply as it is out of the box. Only a number of categories have been added.

1 Answer

+2 votes
by
selected by
 
Best answer

Probably, I understood your wishes.

One solution (Other code may also be necessary...):

  1. Add your override plugin (See here).
  2. Replace qa_get_request_content() function with function below in qa-my-overrides.php​

function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle,
$navcategories, $categoryid, $categoryqcount, $categorypathprefix, $feedpathprefix, $suggest,
$pagelinkparams=null, $categoryparams=null, $dummy=null) {
    $content = qa_q_list_page_content_base($questions, $pagesize, $start, $count, $sometitle, $nonetitle,
    $navcategories, $categoryid, $categoryqcount, $categorypathprefix, $feedpathprefix, $suggest,
    $pagelinkparams, $categoryparams, $dummy);
    $navkeys = array('activity', '$', 'questions', /*'hot', 'unanswered'*/);
    if(is_numeric($categoryid)) {
        $catreq = qa_category_path_request($navcategories, $categoryid);
        if(isset($content['navigation']['main'])) {
            $navs = &$content['navigation']['main'];
            foreach($navs as $key => $nav) {
                if(in_array($key, $navkeys)) {
                    if(substr($navs[$key]['url'], -1) != '/')
                        $navs[$key]['url'] .= '/';
                    $navs[$key]['url'] .= $catreq;
                }
            }
        }
    }
return $content;
}

by
Perfect, this works exactly the way I intended it. Now I know where to start to maybe add the option to include/exclude certain categories for this behaviour. Thanks!
...