Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
1.8k views
in Q2A Core by
I would like to display the category discription at the top of list of questions of that category. How can I do that?

I mean when we create a category we as well can provide a brief discript of that category which appears at the time the user want to select a category. However samediscription I would like to display at the top of list of questions of that category, or somewhere. How can I do that?
Q2A version: 1.5.4, 1.6.1

1 Answer

+4 votes
by
edited by
 
Best answer

This is core hack.

qa-include/qa-app-q-list.php (L70 [case of V1.6.1])

Add lines below.

// add [start]
if(isset($categoryid)) {
  $catinfo = qa_db_single_select(qa_db_full_category_selectspec($categoryid, true));
  $html  = '';
  /*
  $html .= '<PRE>';
  $html .= 'categoryid = '. print_r($categoryid,true)."\n";
  $html .= 'catinfo = '. print_r($catinfo,true)."\n";
  $html .= '</PRE>';
  */
  $html .= '<P class="qa-category-desc">';
  $html .= $catinfo['content'].' ( <SPAN class="qa-category-q-count">'.$catinfo['qcount'].'</SPAN> questions   )';
  $html .= '</P>';
  $qa_content['custom'] = $html;
}
// add [end]
P.S.
Because custom field is displayed under question list, you must not hack qa-include/qa-page-questions.php.
by
I couldn't get this to work, would it be the same for 1.6.2?
by
I confirmed in V1.6.2. I carried out procedure below in *V1.6.2* and confirmed it.

1. Apply upper change to core source of Q2A.
2. "admin" > "categories" > Click  specific category
3. Input some phrase in "Optional category description"
4. Click "Save changes"
5. Click "Categories" of main manu
6. Click "xx questions" link of specific category

Description that I input with 3 under title of "Recent questions in xxxxxxxx" page were displayed.
by
Thanks sama55, got it working think it was a formatting problem.
by
Would be perfect if we could add a list of all subcatergories underneath but I guess that's out of scope
...