Counting forum topic posts by user

Hi, I'm looking to extend the group forum topic view by including the amount of posts a user has made inside the group.

I'm having a little trouble with it. I've seen how the vanilla groups plugin counts annotations for each forum topic, but I'm not sure how to tell elgg that I want to count annotations based on a specific user's guid.

Any help would be appreciated. I can follow simple instructions, but I'm not really a coder.

I've found the following:

 $count_annotations = $f->countAnnotations("group_topic_post");

and 

.elgg_echo('groups:posts').": " . $count_annotations . "

Thanks in advance

  • Just realized that. So I tried the countAnnotations code, but I get the error:

    ElggAnnotations::countAnnotations is an unrecognized function.

    Looks like I can't count annotations inside an annotation file. Depressing as this would be a very useful thing to have. A lot of my users are confused by groups because they are used to forums. So if I can make the groups discussions look more like forums they can understand better.

     

  • isn't countAnnotations a function of ElggEntity, not ElggAnnotation?

  • I think so, so I'm completely stuck and have no idea how to proceed.

    Aaahh! I wish I had time to study php more carefully. I'll have to put this one on hold for a while and then come back to it with fresh eyes.

    Thanks for your thoughts Evan.

  • Without 1.7, I'm thinking you'll have to get all the forum topic entities, then loop through those and build up a count of all the annotations that have been added by the given user.  The end sum is the count you want.

  • $river = elgg_view_river_items($subject_guid, 0, $relationship_type, $type, $subtype, '');

    can give you the riverposts for subtype "groupforumtopic", user guid, and topic guid -- might be able to make it work from this angle..

    id     type     subtype     action_type     access_id     view     subject_guid     object_guid     posted
    7     object     groupforumtopic     create     2     river/forum/topic/create     2     21     1261075056

    Yes, I'm shooting 1/2 in the dark ;-)

  • Thanks guys I will try and put this one into action later today. If all goes well I'll release a little plugin when done with the added features for group discussion.

  • *BUMP

    After 364 days I have finally completed this desired bit of code. Simple when you know how...hehe. Robust Groups is working and I'm posting this "spam" just to say I'm so happy today to have completed it and all thanks to elgg and the great community here. Now onto bigger and better features and plugins!!!!