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

This plugin-widget add question followers list. Refer to readme in download-file for detailed usage. 

Compatibility

1.6.x, 1.7 (2014/12/19 Updated)

History

[2014/10/16] V1.0.3 Fix bug (When postid is nothing, error occur)
[2014/03/19] V1.0.2 Fix bug (Dont include CSS at not logged in). And, change layout
[2013/05/23] V1.0.1 Fix small bug (treatment of boolean value)
[2013/04/02] V1.0 First Release

 
This plugin shows simply avatar and name without user's description. I will publish on add-on pageof Q2A after exam time in this thread.

 

Q2A version: 1.6.x, 1.7
by
Nice to see that you have a "plugin run" ;)

Out of interest, why do you program using "self" all over the plugin code? E.g. qa_clicked(self::SAVE_BUTTON). This is kind of confusing for me, as I never did it like that :) (I guess it is correct OOP)
by
Thank you Kai for your response. I do not want to use as same "constant value" if possible in program code from the past experience. Moreover, when copying made plugin and making another plugin, I am using "class constant" abundantly so that it is necessary to change no "constants value" in program code. Experience of PHP is shallow although I have experience of C/C++/VB etc. Therefore, I think that there is much strange code. I am still studying PHP. ^_^;;;
by
edited by
Am getting the following error in the place where the widget is supposed to show:


[quote]A Question2Answer database query failed when generating this page.

A full description of the failure is available in the web server's error log file.[/quote]


Error log file: [Wed Oct 16 14:34:27 2013] [error] [client 127.0.0.1] PHP Question2Answer MySQL query error 1146: Table 'wordpress.qa_users' doesn't exist - Query: SELECT qa_users.userid, handle, points, flags, qa_users.email, avatarblobid, avatarwidth, avatarheight FROM qa_users JOIN qa_userpoints ON qa_users.userid=qa_userpoints.userid JOIN qa_userfavorites ON qa_users.userid=qa_userfavorites.userid WHERE qa_userfavorites.entityid='162' AND qa_userfavorites.entitytype='Q', referer:  http://127.0.0.1/ask/
by
1146 error means that there is no table for the database which you connect. I'm worried about database name called "wordpress". Is the database which you connect right? In addition, it is thought about your table being damaged. I recommend that you confirm the existence of qa_users table by phpMyAdmin or "show tables" query. And try to repaire tables.
by
I was able to fix this. I use Buddypress over Wordpress with QA intergation and this is what I did to fix the issue:
1. In qa-question-followers-widgeet.php around line 285 look for this function and the associated changes I have made below. I have replaced table names to point to wp_users where they need to and changed column names to match. What is not available I have removed from the select statement.
function qa_db_user_favorit_question_selectspec($entityid)
    {
        require_once QA_INCLUDE_DIR.'qa-app-updates.php';
        return array(
            'columns' => array('wp_users.id', 'wp_users.user_nicename', 'qa_userpoints.points', 'wp_users.user_email'),
            'source' => "wp_users JOIN ^userpoints ON wp_users.id=^userpoints.userid JOIN ^userfavorites ON wp_users.id=^userfavorites.userid WHERE ^userfavorites.entityid=$ AND ^userfavorites.entitytype=$",
            'arguments' => array($entityid, QA_ENTITY_QUESTION),
            'sortdesc' => 'qa_userpoints.points',
        );
    }

};


2. Once that is fixed and data is available. Look around line 247. I have changed user[handle] to user[user_nicename] as below

                    $userprofile=qa_db_single_select(qa_db_user_profile_selectspec($user['user_nicename'], false));


3. Look around line 252 for printing the avatars. This is the change you need to do calling buddypress avatar function.
                    $themeobject->output('<SPAN CLASS="qa-question-followers-avatar"><A HREF="'.qa_path_html('user/'.$user['user_nicename']).'" CLASS="qa-user-link" TITLE="'.$user[user_nicename].'">'.bp_core_fetch_avatar( array( 'item_id' => $user[id], 'width' => 20, 'height' => 20,  ) ).'</a></SPAN>');

4. Make sure you change user[handle] to user[user_nicename] wherever you encounter it in this file. And it is good to work with the setup like mine. Similar changes can be done for tag followers widget as well.

1 Answer

+1 vote
by

I am working now on a school site, where people may like a special school (question) which they visited during their life.

Now my 2 questions about this plugin are:

1) What happens if there are 100 or more followers of one question ? Could they be displayed on an extra page through a link in the widget: see all followers ?

2) Is there a way to add the number of followers in a small box like the votes ?

see attached image please:

For a school site the voting option is kind of use less as the votes do not link to the "owners" of the votes.

In a community the follower option is much more important.

 

Thank You for any answer

monk333

by
Thank you monk333 for using my plugin. I support school by volunteer, too.

1) What happens if there are 100 or more followers of one question ?
Because I made this widget when I do not know a lot about Q2A plugin and MySQL, performance is not good when there are many users responding by question. The performance will be improved in narrowing down a record by random condition and LIMIT phrase and JOIN doing the information of the user.

1') Could they be displayed on an extra page through a link in the widget: see all followers ?
There is no feature.

2) Is there a way to add the number of followers in a small box like the votes ?
The total number is displayed in widget.
by
Ok, I understand.

There is another point.
When user hits favorite button his avatar is added to the list.
Now, a user who does not see his avatar may hit again, and so deletes his name from the list again.

Do You see a way to refresh the page when favorite button was hit ?
So user would see his avatar immedeately in the list.
by
I made some similar plugins. In addition, I got how to change view of Q2A dynamically by Ajax at "Notification Pro" plugin's development(Development was over). I cannot promise at the time, but if "Notification Pro" plugin's development was over, I want to improve these plugin to dynamic HTML parts.

http://www.question2answer.org/qa/24522
    ↓    ↓    ↓    ↓    ↓
http://www.question2answer.org/qa/24858/
by
Hi @monk333!
How you implemented number of followers  instead of vote box?
Is it only for questions?
Could you share how to do so? I'd also like to have it instead of vote.
Good job!
...