diff options
Diffstat (limited to 'views/default/page/elements/comments_block.php')
-rw-r--r-- | views/default/page/elements/comments_block.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/views/default/page/elements/comments_block.php b/views/default/page/elements/comments_block.php new file mode 100644 index 000000000..89e43b266 --- /dev/null +++ b/views/default/page/elements/comments_block.php @@ -0,0 +1,33 @@ +<?php +/** + * Display the latest related comments + * + * Generally used in a sidebar + * + * @uses $vars['subtypes'] Object subtype string or array of subtypes + * @uses $vars['owner_guid'] The owner of the content being commented on + * @uses $vars['limit'] The number of comments to display + */ + +$options = array( + 'annotation_name' => 'generic_comment', + 'owner_guid' => elgg_extract('owner_guid', $vars, ELGG_ENTITIES_ANY_VALUE), + 'reverse_order_by' => true, + 'limit' => elgg_extract('limit', $vars, 4), + 'type' => 'object', + 'subtypes' => elgg_extract('subtypes', $vars, ELGG_ENTITIES_ANY_VALUE), +); + +$title = elgg_echo('generic_comments:latest'); +$comments = elgg_get_annotations($options); +if ($comments) { + $body = elgg_view('page/components/list', array( + 'items' => $comments, + 'pagination' => false, + 'list_class' => 'elgg-latest-comments', + )); +} else { + $body = '<p>' . elgg_echo('generic_comment:none') . '</p>'; +} + +echo elgg_view_module('aside', $title, $body); |