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

This has been asked a couple times... but I haven't seen any answers yet.

How can you show the category-list in the sidebar on every page?

At this moment, some pages show the list, others don't.

I'm talking about this function:

            $this->nav('cat', 1);

Which is situated in function sidepanel() ...

Pages that do not show the category list:

  • Users
  • Tags
  • ask a question
  • Unanswered
  • Questions » Hot!
  • Questions » Most votes
  • Questions » Most answers
  • Questions » Most views
  • My Account
  • My Updates

Pages that do show the list:

  • Edit a question
  • All activity
  • Questions » Recent

So what's the logic behind this, and how can you show the list permanently?

Seems like a bug to me in this version, as in 1.4 the list did show-up everywhere.

 

Q2A version: 1.5.1

2 Answers

+7 votes
by
 
Best answer

Alright, I found the solution.

Head over to your qa-theme.php file and search for the sidepanel() function.

Add these two lines of code:

$categories=qa_db_single_select(qa_db_category_nav_selectspec(null, true));
$this->content['navigation']['cat']=qa_category_navigation($categories);

right before:

$this->nav('cat', 1);

This will pass the category list on all pages of your sidepanel.

by
edited by
Hi Aslan! It have a problem, category list not added selected class A tag. How to fix it?
by
this work for me!
by
This works, but then the hover tooltip does not so the category description.
by
Sub-categories are not showing up after adding this code. I have 2 levels of categories and when I click on any of them it doesn't auto-expand to show me the sub-categories under it. Unfortunately, that is must for my site. Please advice if there is a work-around for that as well.
+4 votes
by

If you want to allow browsing by category in more places, switch on the QA_ALLOW_UNINDEXED_QUERIES value in your qa-config.php. If you copied qa-config.php from a pre-1.5 version oif Q2A, add this line:

define('QA_ALLOW_UNINDEXED_QUERIES', true);

This won't add it to every page on your list, but it will add it to pages for which browsing by category makes sense. The other would have to be taken care of via a plugin with a widget.

by
Hmm, bummer. I wish the sidepanel looked the same trough-out the whole website, without any disappearing elements, such as the category list. Isn't there a file where you can manually chose on which pages the list should appear and which not? The switch-on code you provided gave me good results, except for that the category-list still disappears on the search-and login page, which is just what I needed. Anyways, thank you for your quick answer!
by
This also enabled the ability to sort in all category views.   Sweet..
...