hi

When i choose to show, say, only 20 posts in the shoutbox; it will show the 20 FIRST post and no the 20 lasts ones. It is quite anoying....

I have a quick hack to do so:
in shoutbox.module, line 449 ( after " $color = 0; " ),
replace the line $result = db_query("SELECT * FROM {shoutbox} WHERE status=1 ORDER BY created LIMIT %d", $show_amount);
by the lines:

$all_rows = db_query("SELECT * FROM  {shoutbox} WHERE status=1");
  $nb_rows = db_num_rows($all_rows);
  $start_row = $nb_rows - $show_amount;
  if ($start_row < 0)
        {
        $start_row = 0;
        }

  $result = db_query("SELECT * FROM {shoutbox} WHERE status=1 ORDER BY created LIMIT $start_row,$nb_rows);

Hope it will help

Charly

CommentFileSizeAuthor
#1 shoutbox_last_posts.patch.txt863 bytesjonhattan

Comments

jonhattan’s picture

StatusFileSize
new863 bytes

I've fixed it looking at the code in 4.6 version:

$show_start = count_shouts() - $show_amount;
if ($show_start < 0) {
$show_start = 0;
}
$result = db_query("SELECT * FROM {shoutbox} WHERE status=1 ORDER BY created LIMIT %d, %d", $show_start, $show_amount);

attached is a patch

jonhattan’s picture

ooops. anyway, attached was a patch :)

robrepp’s picture

Had the same problem, patch worked fine. See http://drupal.org/node/60108 for detailed instructions on how to apply patches.

cgiscripts4u’s picture

ok why not just order the database in descending order ie change line 446 from

$result = db_query("SELECT * FROM {shoutbox} WHERE status=1 ORDER BY created LIMIT %d", $show_amount);

to

$result = db_query("SELECT * FROM {shoutbox} WHERE status=1 ORDER BY created desc LIMIT %d", $show_amount);

This will show the last entry first.

Greg

disterics’s picture

Status: Active » Closed (fixed)

Don't think this is currently a problem in HEAD. Open this if its still an issue.