Skip to content

Commit

Permalink
Merge pull request #7802 from mrclay/river_discussions
Browse files Browse the repository at this point in the history
fix(plugins): discussion replies no longer missing/reversed order on river
  • Loading branch information
mrclay committed Jan 25, 2015
2 parents 3b3b316 + 78af4b6 commit d0f3ee2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion docs/guides/views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ This is then used in the provided listing functions. To automatically display a
'subtype' => 'blog',
));
This function checks to see if there are any entities; if there are, it first displays the ``navigation/pagination`` view in order to display a way to move from page to page. It then repeatedly calls ``elgg_view_entity`` on each entity, before returning the result.
This function checks to see if there are any entities; if there are, it first displays the ``navigation/pagination`` view in order to display a way to move from page to page. It then repeatedly calls ``elgg_view_entity`` on each entity, before returning the result.

Note that ``elgg_list_entities`` allows the URL to set its ``limit`` and ``offset`` options, so set those explicitly if you need particular values (e.g. if you're not using it for pagination).

Because it does this, Elgg knows that it can automatically supply an RSS feed - it extends the ``metatags`` view (which is called by the header) in order to provide RSS autodiscovery, which is why you can see the orange RSS icon on those pages.

Expand Down
14 changes: 7 additions & 7 deletions mod/groups/views/default/river/elements/discussion_replies.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
$count = elgg_get_entities($options);

if ($count) {

$list_options = array(
$replies = elgg_get_entities(array_merge($options, [
'order_by' => 'e.time_created desc',
'list_class' => 'elgg-river-comments',
'pagination' => false,
'count' => false,
'limit' => 3,
);
]));

$options = array_merge($options, $list_options);
// why is this reversing it? because we're asking for the 3 latest
// comments by sorting desc and limiting by 3, but we want to display
// these comments with the latest at the bottom.
$replies = array_reverse($replies);

echo elgg_list_entities($options);
echo elgg_view_entity_list($replies, array('list_class' => 'elgg-river-comments'));

if ($count > 3) {
$more_count = $count - 3;
Expand Down

0 comments on commit d0f3ee2

Please sign in to comment.