group forum posts

I'm a little unsure of the behaviour going on when I make the following two calls:

$posts = get_annotations($entity_guid = $topic_guid,$entity_type = "object",$entity_subtype = $topic->subtype,$name = "",$value = "",$owner_guid = "",$limit = "",$entity_owner_guid = $topic->owner_guid);

$post_count = $topic->countAnnotations('group_topic_post');
The first call returns a value of 1. The second call returns the correct count of posts on the topic. Why when I count($posts) do I get 1 instead of the same as the second call?
Any thoughts?
  • i think 1st call is coded wrongly - not supplying the owning guid correctly.

  • The issue is with $limit = "". If I set it to 10 or for example 999, then it matches the count. If I set it to "", it doesn't. 

  • example test code works on my xampp, you musta coded too many parms & confoozed the api or not followed my earlier note

     


    CODE (A)

    Get_Annotations Topic=(51) Group(26)

    print_r($posts)Array
    (
    [0] => ElggAnnotation Object
    (
    [attributes:protected] => Array
    (
    [id] => 31
    [entity_guid] => 51
    [name_id] => 105
    [value_id] => 248
    [value_type] => text
    [owner_guid] => 2
    [access_id] => 17
    [time_created] => 1307510667
    [enabled] => yes
    [name] => group_topic_post
    [value] =>

    test 1


    [type] => annotation
    )

    [valid:ElggExtender:private] =>
    )

    [1] => ElggAnnotation Object
    (
    [attributes:protected] => Array
    (
    [id] => 33
    [entity_guid] => 51
    [name_id] => 105
    [value_id] => 250
    [value_type] => text
    [owner_guid] => 2
    [access_id] => 17
    [time_created] => 1307510770
    [enabled] => yes
    [name] => group_topic_post
    [value] =>

    comment 1


    [type] => annotation
    )

    [valid:ElggExtender:private] =>
    )

    [2] => ElggAnnotation Object
    (
    [attributes:protected] => Array
    (
    [id] => 34
    [entity_guid] => 51
    [name_id] => 105
    [value_id] => 251
    [value_type] => text
    [owner_guid] => 2
    [access_id] => 17
    [time_created] => 1307510779
    [enabled] => yes
    [name] => group_topic_post
    [value] =>

    comment 2


    [type] => annotation
    )

    [valid:ElggExtender:private] =>
    )

    )

    COUNT=(3)


    CODE (B)

    Get_Annotations Topic=(51) Group(26)

    print_r($posts)Array
    (
    [0] => ElggAnnotation Object
    (
    [attributes:protected] => Array
    (
    [id] => 31
    [entity_guid] => 51
    [name_id] => 105
    [value_id] => 248
    [value_type] => text
    [owner_guid] => 2
    [access_id] => 17
    [time_created] => 1307510667
    [enabled] => yes
    [name] => group_topic_post
    [value] =>

    test 1


    [type] => annotation
    )

    [valid:ElggExtender:private] =>
    )

    [1] => ElggAnnotation Object
    (
    [attributes:protected] => Array
    (
    [id] => 33
    [entity_guid] => 51
    [name_id] => 105
    [value_id] => 250
    [value_type] => text
    [owner_guid] => 2
    [access_id] => 17
    [time_created] => 1307510770
    [enabled] => yes
    [name] => group_topic_post
    [value] =>

    comment 1


    [type] => annotation
    )

    [valid:ElggExtender:private] =>
    )

    [2] => ElggAnnotation Object
    (
    [attributes:protected] => Array
    (
    [id] => 34
    [entity_guid] => 51
    [name_id] => 105
    [value_id] => 251
    [value_type] => text
    [owner_guid] => 2
    [access_id] => 17
    [time_created] => 1307510779
    [enabled] => yes
    [name] => group_topic_post
    [value] =>

    comment 2


    [type] => annotation
    )

    [valid:ElggExtender:private] =>
    )

    )

    COUNT=(3)

  • I ended up using the following call which works:

    $posts = get_annotations($entity_guid = $topic_guid,$entity_type = "object",$entity_subtype = $topic->subtype,$name = "group_topic_post",$value = "",$owner_guid = 0,$limit = "9999",$entity_owner_guid = 0);

    Thanks for the debugging D.
  • not listen still.. why u code so much ?

    $posts = get_annotations(
        $entity_guid = 51
        ,$entity_type = "object"
        ,$entity_subtype = "groupforumtopic"
        //,$limit = 999 // use default 10
        );
    gets me what i'm searching..

  • yep, but a few things:

    1) if you don't define the $name it could get other annotations attached to that that are not group_topic_posts (if there are other annotation types)

    2) if you use the limit of 10, then it will only get the last 10 posts. Since these are forum topics we are searching it makes sense in general to raise the limit as quite often they will have more than 10 posts.

    It also depends on the reason you are trying to get these annotations. I'm doing a post count across the group, so I need to be able to get more than just 10. Anyway it works, go look at Robust Groups plugin to see. :)

    P.S. You might remember over a year ago I was posting asking about how to count posts in a group. Well it took me a while, but I'm now in the position of being able to code such a thing in an hour from scratch all thanks to perseverance with the elgg system. It really is beautiful!!! (Thanks elgg)