Last comments for Elgg sidebar

How can to add Last comments for Elgg sidebarĀ 

How can to add Last comments for Elgg sidebar

Open or create the file

elgg/mod/MOD_NAME/views/default/MOD_NAME/sidebar.php

And add this code

echo elgg_view('page/elements/comments_block');

Add Last comments for Elgg sidebar

Share on Facebook
Share on Twitter




20 Responses to “Last comments for Elgg sidebar”

  1. Nudeler says:

    How to extend this code, that for example the last – 3 – comments are shown?

    • pianist says:

      Use array () for this…

      Ex.,:
      3 last comments only:
      echo elgg_view('page/elements/comments_block', array(
      'limit' => 3,
      ));

      Comments from Blog only:
      echo elgg_view('page/elements/comments_block', array(
      'subtypes' => 'blog',
      ));

      and

      3 last comments from owner' Bookmarks only:
      echo elgg_view('page/elements/comments_block', array(
      'subtypes' => 'bookmarks',
      'owner_guid' => elgg_get_page_owner_guid(),
      'limit' => 3,
      ));

      Have a nice hackday :)

  2. Nudeler says:

    Great. Thank you.

  3. Nudeler says:

    For to show only all comments of the owner then to code this?

    'subtypes' => 'bookmarks',
    'subtypes' => 'thewire',
    'subtypes' => 'activity',

    e.c.

    • pianist says:

      Add this code:
      echo elgg_view('page/elements/comments_block');
      In the file
      elgg/mod/MOD_NAME/views/default/MOD_NAME/sidebar.php for MOD\PLUGIN
      when you want to show comments for it.

      Ex., for TheWire add this code in:
      elgg/mod/thewire/views/default/thewire/sidebar.php
      or create this file

      No need to use array() for it…

      But if you want to show last comments for TheWire on the Bookmarks page…yes…need use array() function for that subtype…
      Ex., last comments from TheWire' posts on the Bookmarks sidebar:
      Open the file
      elgg/mod/bookmarks/views/default/bookmarks/sidebar.php
      And add this code
      echo elgg_view('page/elements/comments_block', array(
      'subtypes' => 'thewire',
      ));
      Now you can to see last comments for TheWire on the Bookmarks sidebar

      Also, if you want to show last comments from OWNER only..yes…in all examples and variants you need to add this code:
      echo elgg_view('page/elements/comments_block', array(
      'subtypes' => 'YOUR_SUBTYPE',
      'owner_guid' => elgg_get_page_owner_guid(),
      ));
      Because without 'owner_guid' => elgg_get_page_owner_guid(), will shown ALL last comments from ALL users for that subtype..

      Sorry for the many words ;)

  4. Nudeler says:

    Thanks again for your efforts.

  5. Ku Bin says:

    I use plugin in this article http://elgghacks.com/custom-html/
    Added file to:
    elgg\mod\customhtml\views\default\customhtml\sidebar.php

    with content:
    <?php
    echo '<h2> sidebar custom HTML </h2>';
    echo elgg_view('page/elements/comments_block');

    But there is no result.
    Please explain.

    • pianist says:

      U need to add sidebar to view section:

      Open the file:
      elgg\mod\customhtml\index.php
      And change this code:
      $body = elgg_view_layout('content', array(
      'content' => $content,
      'title' => $title,
      'filter' => '',
      ));
      With this:
      $body = elgg_view_layout('content', array(
      'content' => $content,
      'title' => $title,
      'filter' => '',
      'sidebar' => elgg_view('customhtml/sidebar'),
      ));

  6. Ceeblaj says:

    hi I use hypeAlive for comment and like so I want to remove the default comment text next to * days ago.

    Please help me!

  7. Nudeler2 says:

    Hi pianist!

    Have a question again.

    Had created some widgets on customindex.

    But this one doesn't work (comments on custumindex):

    $options = array(
    'limit' => 5,
    'full_view' => FALSE,
    'pagination' => false,
    );

    if (elgg_is_logged_in())
    $content = elgg_view_comments($options);
    echo elgg_view_module('featured', elgg_echo("custom:comments"), $content, $mod_params);
    elgg_pop_context();

    What ist missing or wrong, please?

    • pianist says:

      Hi Nudeler2 ;)

      Do you want to display the comments on Custom Index page as a widget?

      If 'yes' then you need using the object subtype string or array of subtypes.

      What the subtype's comment you want to show on the CustomIndex page? Blog? Wire? Discussion aka Forum?

      So, check 'subtypes' in your 'array()' code

      Also, need to return the owner of the content being commented on.
      It's an 'owner_guid' string in your code

      Finally, extract the 'annotation_name' for the comments displaying

      What about this code:

      $owner_guid = elgg_extract('owner_guid', $vars, ELGG_ENTITIES_ANY_VALUE);
      if (!$owner_guid) {
      $owner_guid = ELGG_ENTITIES_ANY_VALUE;
      }

      $options = array(
      'annotation_name' => 'generic_comment',
      'owner_guid' => $owner_guid,
      'type' => 'object',
      'subtypes' => 'blog',
      'limit' => 5,
      'full_view' => FALSE,
      'pagination' => false,
      );

      $content = elgg_view_comments($options);

Leave a Reply



Similar Elgg Hacks