1

I am trying to copy the "thanked"-function seen in vBulletin forums. Here the author of a topic can thank the author of a comment and the number of comments a person have been thanked for is shown in the author pane.

I have used the Flag module to allow a comment-specific flag but I can't figure out how to display the count number of thanks for each user. I have tried to create a view and display it with views_embed_view but i don't know how to choose count for the specific author? I have also thought of using entityfieldquery but I don't think it can see which comments that are flagged?

Is there a solution to my problem?

3
  • Query the flag_counts table directly?
    – Felix Eve
    Commented Feb 26, 2014 at 16:34
  • I am not shure how to do that. I have tried with db_query("SELECT COUNT(*) FROM flagging WHERE uid = :uid AND fid = 2", array(':uid' => $uid))->fetchField()
    – Morten
    Commented Feb 26, 2014 at 20:57
  • I haven't actually used the module so I'm not sure what the exact query you would need is but I think your on the right track...
    – Felix Eve
    Commented Feb 27, 2014 at 9:02

1 Answer 1

0

Ok so I found a solution although I am not sure it is the best one. The problem was that the databases for the flag module only stores the comment id (when using a comment flag) and not the id of the authoring user. I am implementing the code in a PHP snippet in author pane template where the comment object isn't available. My solution was to do two queries:

$cid_array = db_query("SELECT cid FROM comment WHERE uid = :user", array(':user' => $account->uid))->fetchCol();
$thank_count = db_query("SELECT COUNT(*) FROM flagging WHERE entity_id IN (:cid) AND fid = 2", array(':cid' => $cid_array))->fetchField();

Thanks to Felix Eve for supportive comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.