Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+6 votes
8.0k views
in Q2A Core by
How can I add tag to sidebar? any code? it is very nice and useful. how beta 3 have more features.
Best;
MK

2 Answers

+1 vote
by
edited by
Not so easy at the moment, I'm afraid. There would be 3 stages involved:

1. You can retrieve the most popular tags as part of a page's access to the database by modifying the qa_db_select_with_pending(...) function on the appropriate page to use qa_db_popular_tags_selectspec(0). For example on the questions page, you could change this in qa-page-home.php:

list($questions, $count)=qa_db_select_with_pending($qa_db,
    qa_db_recent_qs_selectspec($qa_login_userid, $qa_start),
    qa_db_options_cache_selectspec('cache_qcount')
);

...to...

list($questions, $count, $populartags)=qa_db_select_with_pending($qa_db,
    qa_db_recent_qs_selectspec($qa_login_userid, $qa_start),
    qa_db_options_cache_selectspec('cache_qcount'),
    qa_db_popular_tags_selectspec(0)
);

2. Lower down on the same page, after qa_content_prepare(), add the $populartags variable to $qa_content, perhaps as follows:

$qa_content['populartags']=$populartags;

3. Create a custom theme (see Advanced page on main site) and override the sidebar() function to do something with $this->content['populartags']. To start with you can print_r it, just to get an idea of what it contains. You can use qa_tag_html() to convert a tag to the standard HTML representation.

Good luck and let us know how it goes!
by
with this solution give me error Notice: Undefined variable: populartags in /home/asgamer/public_html/qa-include/qa-page-home.php  on line 130
by
edited by
Thx gidgreen. I really added it. It became such a below feeling.
(Now: only home/questions/unanswered, but single question page ...?)
http://qa.modxclub.net/
>> gidgreen
Because editing operation is hard, then had better separate sidebar-source from other source... ?
by
Thank you Gidgreen for your valuable suggestion.

But im getting following error:
"Notice: Undefined variable: populartags in /var/www/qa-include/qa-page-home.php on line 145"
In tags page in side bar, getting below error:
"Notice: Undefined index: populartags in /var/www/qa-include/qa-theme-base.php on line 325"

Could you please help me on this?
by
Step 1 needs to be done for all the different page requests you want to support, not just in one place. Also, in your theme file, you should first check if $qa_content['populartags'] is defined before trying to access it, since there will be some pages for which it isn't retrieved (since you haven't yet done step 1 for them). So it also might be easier just to wait for categories...!
by
aha! Nice, thanks for the note about advanced themes.
+1 vote
by
or use simple links...the way I'm doing.

check here
http://Answers.ProThoughts.com
...