Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
1.7k 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
Thank you Sama55
by
Sama55 can you please implement this feature as plugin? It's urgently needed. Please see this topic:  http://www.question2answer.org/qa/14633/how-to-using-enhanced-category-description-on-page
by
I read topic. monk333 seems to know a lot than me. I observed core code well, and I judged that I should not cope it in plugin. I don't write detailed reasons. However, I think this matter should be coped in core. Sorry.
by
Oh, sama55, I read this, but You know much more then me !

The code of the other post goes in custom qa-theme in function
function main()

directly after

$this->page_title_error();   

no core files are affected.

Code could be better, I am sure, but for the moment it works.
I dont know about plugins...
by
@monk333 Thank you for your comment. I understand that category-top-page is very important for the QA site where category's priority is high. However, I judged that current Q2A was not made to be suitable for those usage yet. For example, category description are limited in 800 characters. This field size is unsuitable for HTML. It is easy to expand the field in ALTER of MySQL, but it is not enough. Because this is my judgment, of course, other thoughts will exist. I want to hear founder's opinion. Gideon surely makes a better reply.
by
You are right, i think. category description on category pages should be a core feature, not a work around. I am as well interested what Gideon is planing in this direction.
by
Agree, it should have been a core feature.
by
Gidgreen, is it possible to add such feature (category description) in new Q2A releases?
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
...