20 Responses to “Last comments for Elgg sidebar”
Leave a Reply
Similar Elgg Hacks
- Custom Tabs ← (4 responses) |
Remove Display name ← (24 responses) |
Add links to User hover menu ← (2 responses) |
Sort Members in alphabetical order ← (No responses yet) |
Elgg widgets ordering ← (No responses yet) |
Featured Pages ← (8 responses) |





How to extend this code, that for example the last – 3 – comments are shown?
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
Great. Thank you.
For to show only all comments of the owner then to code this?
'subtypes' => 'bookmarks',
'subtypes' => 'thewire',
'subtypes' => 'activity',
e.c.
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
Ah..Don't forget to add
<?php
before your hack code if you create new php-file
Thanks again for your efforts.
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.
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'),
));
Thanks for your help!
P/S: Your site maybe is cached. I can not view my reply and your post after refresh page. I have to use another browser or clean cookies
Thanks for debugging!
hi I use hypeAlive for comment and like so I want to remove the default comment text next to * days ago.
Please help me!
Best way is an installation the Flexible FriendlyTime plugin:
You can to set your own formats for time display with it
Thanks
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?
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);
Done: http://weborganizm.org/totemz/v/2015/elgg-hacks#up_1134
Thanks for reply, but this is like a labyrinth for me, I tested around, bit can't get it run. Too 'much' for me, as a not-coder.
What to do in index.php and what to do in customindex.php ??
I would like to create one widget in customindex page with latest comments from all of these:
blog, phloor_news, groups (discussions?), phloor_band, phloor_lyrics, top_page (page?), river (activity?), thewire, album, image :/
It's very easy: http://weborganizm.org/totemz/v/2015/elgg-hacks#up_1147
Many thanks!
It's running now.
There was some wrong code in my index.php :/