It's possible to change the order of comments (from ascending to descending) and the number of comments that show up when they are collapsed (via javascript). When set to (say) 2 collapsed comments in an ascending fashion you see the following:

Show all 3 comments
Suzy: Your writing style is wretched. 1:15pm
Thomas: I'm dyslexic - can you blame me? 2:30pm

Then when uncollapsed:

Suzy: Your writing style is wretched. 1:15pm
Thomas: I'm dyslexic - can you blame me? 2:30pm
Suzy: that's no excuse for bad writing. 3:48pm

It would make sense to me to display the last two of the ascending comments then it would be to display the first two. This way people can easily check to see how the conversation is evolving without uncollapsing the comments. If we could have an option to enable this or if this could be made to happen by default that would be amazing.

Thanks,
Thomas

CommentFileSizeAuthor
#9 Screen shot 2010-04-26 at 1.49.05 PM.png33.42 KBpribeh

Comments

Scott Reynolds’s picture

Status: Active » Needs review

Click the Field in the View and you have your options. There you can change the number of collapsed comments and their order (ASC or DESC).

pribeh’s picture

Hi Scott, thanks for responding. As I mentioned I'm aware of the options to change the order of the Activity comments. What I'm requesting is (the option) to display the latest comments (last of ascending order) within the collapsed state. On Facebook the comments pertaining to an activity are displayed this way as it helps users easily keep track of discussions without having to uncollapse the comments.

Right now, if I were to display Activity comments in ascending order the first two (by default) comments would show up in the collapsed state. So instead, as according to my request, activity comments would display as follows.

When collapsed:

Show all 4 comments
Suzy: that's no excuse for bad writing. 3:48pm
Thomas: Perhaps you're write - pun intended :) 4:00pm

Then when uncollapsed:

Suzy: Your writing style is wretched. 1:15pm
Thomas: I'm dyslexic - can you blame me? 2:30pm
Suzy: that's no excuse for bad writing. 3:48pm
Thomas: Perhaps you're write - pun intended :) 4:00pm

Thanks for your time, Scott.

pribeh’s picture

Hi Scott,

I was wondering if you'd be willing to give this some thought again. I know you're busy. I've fumbled around with the module's code but am no php expert so can't get this to work myself. I think it makes total sense to have the option to setup activity comments to display like Facebook's comments do when collapsed.

Thanks

Scott Reynolds’s picture

Interesting well it would take reversing the way comments are hidden. so instead of hiding all the comments after the limit you reverse it and hide all comments before the limit. So you override the theme function

/**
 * Theme up all the comments
 */
function MYTHEME_activity_comments_comments($aid, $comments = array(), $limit = 10) {
  $items = array();
  $count = 0;
  foreach($comments as $comment) {
    $hide = (++$count < $limit); // Changed this line.
    $classes = 'activity-comment-wrapper';
    if ($hide) {
      $classes .= ' activity-comment-hidden';
    }
    $items[] = array(
      'data' => theme('activity_comments_comment', $comment),
      'class' => $classes,
    );
  }
  return theme('item_list', $items, NULL, 'ul', array('id' => 'activity_comments-'. $aid, 'class' => 'activity-comment-list'));
}
pribeh’s picture

Wow, almost works perfectly just after plopping in the above code into my template file (and flushing caches of course). For some reason though once the comment count reaches four or more than all of the comments (minus the first) display off the bat along with "Show all X comments". I'm fiddling but can't figure it out :)

Scott Reynolds’s picture

haha thats what I get for taking a shortcut.

/**
* Theme up all the comments
*/
function MYTHEME_activity_comments_comments($aid, $comments = array(), $limit = 10) {
  $items = array();
  $count = 0;
  $total_comments = count($comments); // Add this.
  foreach($comments as $comment) {
    $hide = (++$count < ($total_comments  - $limit)); // Changed this line.
    $classes = 'activity-comment-wrapper';
    if ($hide) {
      $classes .= ' activity-comment-hidden';
    }
    $items[] = array(
      'data' => theme('activity_comments_comment', $comment),
      'class' => $classes,
    );
  }
  return theme('item_list', $items, NULL, 'ul', array('id' => 'activity_comments-'. $aid, 'class' => 'activity-comment-list'));
}
pribeh’s picture

Amazing. Thank you. I owe you a beer or several.

Scott Reynolds’s picture

Status: Needs review » Fixed
pribeh’s picture

StatusFileSize
new33.42 KB

Wicked, thanks for this Scott, just one last issue with it though. Say I have my view setup to display two comments by default (collapsed state). The "show-all" box still shows when only two comments have been added. I've attached a screen to illustrate what I mean.

Scott Reynolds’s picture

Title: Collapsed comments should show last X number of comments » Show all shouldn't be shown when number of comments less than or equal to limit.
Status: Fixed » Postponed (maintainer needs more info)

hmm interesting, does it show up even when there is only one comment? The form controls the visibility of that link

 // show all
  $form['show_all'] = array(
    '#prefix' => '<span class="activity-comment-show-all">',
    '#value' => '<a href="#">' . t('Show all !plural', array('!plural' => format_plural(count($items), '1 comment', '@count comments'))) . '</a>',
    '#suffix' => '</span>',
    '#weight' => -11,
    '#access' => count($items) > $limit,
  );

Essentially it says "If the total number of items is greater then limit, allow access to this link".

Are you by chance, form altering the comment form? I actually couldn't reproduce.

pribeh’s picture

No, it doesn't show if only there's only one comment. I have the view setting to display two by default and only once there are two comments added does the "show-all" link display. It displays properly afterward, so if there are three comments, it will only display two by default along with "show all 3 comments". I'm not doing any form altering. I've simply placed the above code from #6 into my template.php. Thanks Scott.

Scott Reynolds’s picture

Status: Postponed (maintainer needs more info) » Needs review

Did you get this fixed? Did you try just adding a -1 on that line as well? like so?

/**
* Theme up all the comments
*/
function MYTHEME_activity_comments_comments($aid, $comments = array(), $limit = 10) {
  $items = array();
  $count = 0;
  $total_comments = count($comments); // Add this.
  foreach($comments as $comment) {
    $hide = (++$count < ($total_comments  - $limit - 1)); // Changed this line.
    $classes = 'activity-comment-wrapper';
    if ($hide) {
      $classes .= ' activity-comment-hidden';
    }
    $items[] = array(
      'data' => theme('activity_comments_comment', $comment),
      'class' => $classes,
    );
  }
  return theme('item_list', $items, NULL, 'ul', array('id' => 'activity_comments-'. $aid, 'class' => 'activity-comment-list'));
}
pribeh’s picture

Hi Scott,

Thanks for providing some more input. Using the above #12 actually begins to display 3 comments in the same way it does for 2 comments for me. So if an activity has three comments it will display 3 comments along with "display all 3 comments".

Scott Reynolds’s picture

o well then do a '+1' instead of the '-1'.

pribeh’s picture

Sweet, works perfectly. Thanks so much Scott!

Scott Reynolds’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.