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

I am using Q2A 1.7 with the Snow theme. In the menu we have a link "All Activity" and another link "Questions". I would like to add the "All activity" link to the submenu (see bellow) which appears when you click on "Questions":

Submenu: "Recent     Hot!     Most votes     Most answers     Most views   All Activity"

How to add this ?

Q2A version: 1.7

1 Answer

+3 votes
by
selected by
 
Best answer

I've been thinking on the simplest way to solve this without a core hack and I think I've cracked it. Follow these steps:

1. Edit the qa-theme/<your-theme>/qa-theme.php file

2. Add (or merge, if it already exists) this function:

public function initialize() {
    $request = 'activity';
    $categorySlugs = qa_request_parts(1);
    if (isset($categorySlugs)) {
        foreach ($categorySlugs as $slug) {
            $request .= '/' . $slug;
        }
    }
    $activityNav = array(
        'url' => qa_path_html($request),
        'label' => qa_lang_html('main/nav_activity'),
    );
    switch ($this->template) {
        case 'questions':
            $this->content['navigation']['sub']['activity'] = $activityNav;
            break;
        case 'activity':
            $fullSubNav = qa_qs_sub_navigation(null, categorySlugs);
            $activityNav['selected'] = true;
            $fullSubNav['activity'] = $activityNav;
            $fullSubNav['recent']['selected'] = false;
            $this->content['navigation']['main']['activity']['selected'] = false;
            $this->content['navigation']['main']['questions']['selected'] = true;
            $this->content['navigation']['sub'] = $fullSubNav;
        default:
    }
    parent::initialize();
}

This way, the Questions section would be similar to the Activity section. You might want to disable the All Activity navigation link in admin/pages.

by
Works perfectly, thanks :)
...