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
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
Can anyone tell me why this doesn't work?
Ok, I've tried a lot of things. I'm currently looking at something like this.
But I still get the result of 0 no matter how many posts I make. Could it be that it won't display inside itself?
Can anyone help me?
function list_entities_from_annotations($entity_type = "", $entity_subtype = "", $name = "", $value = "", $limit = 10, $owner_guid = 0, $group_guid = 0, $asc = false, $fullview = true, $viewtypetoggle = false) {
maybe ?;-)
discussions.php -->
// Load Elgg engine
require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
group_gatekeeper();
// Display them
$area2 = elgg_view_title(elgg_echo("groups:latestdiscussion"));
set_context('search');
$area2 .= list_entities_from_annotations("object", "groupforumtopic", "group_topic_post", "", 40, 0, 0, false, true);
set_context('groups');
$body = elgg_view_layout("two_column_left_sidebar", '', $area2);
Thanks Dhrup, very kind of you.
@T,
Hope that helps.. ;-) I have not done any heavy research into the code, but I do believe that that is the code you need to play with;-O Let me know when you get that working, cheers ;-)
Thanks Dhrup. Still struggling with it but getting closer. The code I'm using is the following:
All of this is inside the groups/views/default/forum/topicposts.php file
It is giving me a result now, but not quite what I was expecting. Here is some feedback:
setting $limit to 0 counts every single discussion topic on the site. This disregards the following bit of code:
And just counts all discussion topics no matter the group wuid or owner guid.
setting $limit to 1 gives me a count of 0
setting $limit to 2 gives me a count of 1
At the moment I have started 2 topics in that group, but $postcount has never read as 2 yet.
I will get this eventually.
Sorry I should have mentioned what I'm looking to get is a combined count of both groupforumtopics and group_topic_posts for a single user inside a single group. I've added a little group rank as well which is working. Here is an example of the view:
If I understand correctly: what you want is a count of all annotations named "group_topic_post" which are annotating objects of subtype "groupforumtopic" in a certain group. Is that correct?
Are you running 1.7+ by any chance?
That's essentially right. I'm not running 1.7+, I'm on 1.6.1 due to plugin requirements.
ount of all annotations named "group_topic_post" which are annotating objects of subtype "groupforumtopic" by a certain user in a certain group.
If user then goes and posts in another group that he is a member of, it will show a different post count depending on the number of group_topic_posts he has made in that group.
I wanted to include the actual groupforumtopic as a post count as well but that would involve counting two different things which is far beyond my meagre talents.
Still struggling with this. The code I've got going now is the following. Please could anyone spare 5 minutes to check whether it actually makes sense. I'm still returning a post count of 0.
Then outputting like this:
You don't need to "stringify" your variables. In particular, this one ("page_owner_entity()->guid") is not doing what you expect. Also, the function you're using is "list_entities". But you actually want to count the annotations, so you're never going to get a correct count with this.
- Previous
- 1
- 2
- Next
You must log in to post replies.