The digests in notifications are great but we have run into one issue. Nodes get sent out as node teasers with "read more" links which make sense. But if your digest contains comments, it includes the *full* comment instead of a snippet.

In digest mode, this doesn't make sense. *Everything* should be in a snippet to keep it consistent.

Or perhaps a new option to set "notifications digest entry length" that trims nodes & comments to same length before sending...

Comments

m3avrck’s picture

This is the trim text function I use on all of my projects...

/**
 * Trim a post to a certain number of characters, removing all HTML.
 */
function trim_text($text, $length = 150) {
  // remove any HTML or line breaks so these don't appear in the text
  $text = trim(str_replace(array("\n", "\r"), ' ', strip_tags($text)));
  $text = trim(substr($text, 0, $length));
  $lastchar = substr($text, -1, 1);
  // check to see if the last character in the title is a non-alphanumeric character, except for ? or !
  // if it is strip it off so you don't get strange looking titles
  if (preg_match('/[^0-9A-Za-z\!\

/', $lastchar)) {
$text = substr($text, 0, -1);
}
// ? and ! are ok to end a title with since they make sense
if ($lastchar != '!' and $lastchar != '?') {
$text .= '...';
}

return $text;
}
?>

m3avrck’s picture

Hmm that got broke, maybe this works better:

/**
 * Trim a post to a certain number of characters, removing all HTML.
 */
function trim_text($text, $length = 150) {
  // remove any HTML or line breaks so these don't appear in the text
  $text = trim(str_replace(array("\n", "\r"), ' ', strip_tags($text)));
  $text = trim(substr($text, 0, $length));
  $lastchar = substr($text, -1, 1);
  // check to see if the last character in the title is a non-alphanumeric character, except for ? or !
  // if it is strip it off so you don't get strange looking titles
  if (preg_match('/[^0-9A-Za-z\!\?]/', $lastchar)) {
    $text = substr($text, 0, -1);
  }
  // ? and ! are ok to end a title with since they make sense
  if ($lastchar != '!' and $lastchar != '?') {
    $text .= '...';
  }

  return $text;
}
jose reyero’s picture

Category: bug » feature

Not sure what you mean about the digest mode. The default line should be: 'New comment by [comment-author-name]: [comment-title]' as defined on notifications_content module, unless you've added some theming there.

Whatever, we are using tokens for all text replacement, it should be possible to have a token for comment-teaser...

jose reyero’s picture

Status: Active » Closed (won't fix)

About tokens, this would be a nice feature request for token module.