Display latest 5 groups posts on custom index

Hello everyone.

 

So I'm using elgg since like 8 monthes and it's been a cool experience. Currently on 1.7.9.

 

I'm using a tweeked version of custom index (3 columns, etc), but I have a question. I created a special group for my website news, and I wanted to display like the latest 5 ou 10 group blog posts on custom index. Since it's basically what the widget blog on the group page does, I figured out it shoudn't be that difficult.

 

Any help ? Thank a lot !

  • Something like this code but tweaked I think :

     

    <?php

     

    //get the num of blog entries the user wants to display

    $num = $vars['entity']->num_display;

     

    //if no number has been set, default to 4

    if (!$num) {

    $num = 4;

    }

     

    $context = get_context();

    set_context('search');

    $content = elgg_list_entities(array('types' => 'object', 'subtypes' => 'blog', 'container_guid' => $vars['entity']->owner_guid, 'limit' => $num, 'full_view' => FALSE, 'pagination' => FALSE));

    set_context($context);

     

    echo $content;

     

    if ($content) {

    $blogurl = $vars['url'] . "pg/blog/owner/" . page_owner_entity()->username;

    echo "<div class=\"widget_more_wrapper\"><a href=\"{$blogurl}\">".elgg_echo('blog:moreblogs')."</a></div>";

    }

  • How can I twek this code to choose the goup whom blog posts I want to display on custom index ?

     

    Many thanks ;)

  • Set the container guid to the group guid value

  • Something like this ?  (1111111 being arbitrary) 

     

    <?php

    $num = 5;

    $context = get_context();

    set_context('search');

    $content = elgg_list_entities(array('types' => 'object', 'subtypes' => 'blog', 'container_guid' => 111111111, 'limit' => $num, 'full_view' => FALSE, 'pagination' => FALSE));

    set_context($context);

    echo $content;

    if ($content) {

    $blogurl = $vars['url'] . "pg/blog/owner/" . page_owner_entity()->username;

    echo "<div class=\"widget_more_wrapper\"><a href=\"{$blogurl}\">".elgg_echo('blog:moreblogs')."</a></div>";

    }

     

    Is this needed ? :

     

    if ($content) {

    $blogurl = $vars['url'] . "pg/blog/owner/" . page_owner_entity()->username;

    echo "<div class=\"widget_more_wrapper\"><a href=\"{$blogurl}\">".elgg_echo('blog:moreblogs')."</a></div>";

    }