show latest blog topics on sidebar when reading a blog elgg 1.8.3

I'm trying to show the latest blog topics on the sidebar when a user is reading a blog. I'm using elgg 1.8.3. I tried copying to the file mod/blog/views/default/blog/sidebar.php the code below:

// blogs

if (elgg_is_active_plugin('blog')) {

echo elgg_view_module('featured',  elgg_echo("custom:blogs"), $vars['blogs'], $mod_params);

}

 

this is what i get when i use that code:

image

 

The header for latest blog post shows, but it does not list the latest blog posts. how can i make this work?

  • i fiured it out. in the file mod/blog/views/default/blog/sidebar.php i copied the code below at the end of that file:

     

    $group = elgg_get_page_owner_entity();

     

    if ($group->blog_enable == "no") {

    return true;

    }


    $all_link = elgg_view('output/url', array(

    'href' => "blog/group/$group->guid/all",

    'text' => elgg_echo('link:view:all'),

    'is_trusted' => true,

    ));


    elgg_push_context('widgets');

    $options = array(

    'type' => 'object',

    'subtype' => 'blog',

    'container_guid' => elgg_get_page_owner_guid(),

    'metadata_name_value_pairs' => array('name' => 'status', 'value' => 'published'),

    'limit' => 6,

    'full_view' => false,

    'pagination' => false,

    );

    $content = elgg_list_entities_from_metadata($options);

    elgg_pop_context();


    if (!$content) {

    $content = '<p>' . elgg_echo('blog:none') . '</p>';

    }


    $new_link = elgg_view('output/url', array(

    'href' => "blog/add/$group->guid",

    'text' => elgg_echo('blog:write'),

    'is_trusted' => true,

    ));


    echo elgg_view('groups/profile/module', array(

    'title' => elgg_echo('blog:group'),

    'content' => $content,

    'all_link' => $all_link,

    'add_link' => $new_link,

    ));

  • i have another issue. when i used the code above, i was able to put the latest blog topics in the sidebar for the groups, but when i click the blogs link in the menu bar at the top of the page that lists "All site blogs", the page is messed up now

  • anybody have any idea on how to do this???

  • Use this code it will display all latest blogs:-

    if (elgg_is_active_plugin('blog')) {
    elgg_push_context('widgets');
    $options = array(
        'type' => 'object',
        'subtype' => 'blog',
        'limit' => 5,//$num,
        'full_view' => FALSE,'list_type' => 'list',
        'pagination' => FALSE,
        );
    $content = elgg_list_entities($options);
    echo elgg_view_module('featured',  elgg_echo("Recent Blogs"), $content);
    elgg_pop_context();
    }

  • thanks a lot! i really appreciate your help!