/**
 * Show paged view of full list of shouts.
 */
function shoutbox_page_view() {
  drupal_add_css(drupal_get_path('module', 'shoutbox') .'/shoutbox.css');
  drupal_add_js('misc/jquery.form.js');
  drupal_add_js(drupal_get_path('module', 'shoutbox') .'/shoutbox-form.js', 'module');
  
  // Output the existing shoutbox posts.
  $show_amount = 30;
  $shoutbox_ascending = variable_get('shoutbox_ascending', FALSE);
  $shoutbox_posts_data = _shoutbox_display_posts($show_amount, TRUE, TRUE);
  
  // Output the shoutbox form.
  if (_shoutbox_user_access('post shouts') || _shoutbox_user_access('post shouts without approval')) {
    $output .= drupal_get_form('shoutbox_add_form');
  }
  else {
    $output .= theme('shoutbox_post_forbidden');
  }

  $default_nick = t('Your Name/Nick');
  $default_msg = t('Enter Message');
  $default_url = t('Your Website URL');

  // Variable needed by javascript code.
  $js_settings = array(
    'showAmount' => $show_amount,
    // Convert to milliseconds.
    'refreshDelay' => (1000 * variable_get('shoutbox_refresh', 0)),
    'ascending' => $shoutbox_ascending,
    'shownAmount' => $shoutbox_posts_data['count'],
    'defaultNick' => $default_nick,
    'defaultMsg' => $default_msg,
    'defaultUrl' => $default_url,
    'refreshPath' => url('shoutbox/js/view'),
  );

  drupal_add_js(array('shoutbox' => $js_settings), 'setting');
  
  //$output .= theme('table', array(), $shoutbox_posts_data['rows']);
  $output .= theme('shoutbox_page', $shoutbox_posts_data['output'], $title);
  $output .= theme('pager', NULL, 20, 0);

  return $output;
}
CommentFileSizeAuthor
#7 shoutbox.tar_.gz30.69 KBmstef

Comments

disterics’s picture

Thanks. Would be nice to get it in a patch file.

mstef’s picture

never issued a patch before so i'm not sure how to do it. just replace the given function with the one above. also, there is no admin setting for the amount of items displayed on the page (see $show_amount).

4strO’s picture

Whatever number i chose for $show_amount, after the javascript refresh it take the number define in admin setting to display items

mstef’s picture

Hmm maybe you need to change the 20 in the theme_pager to $show_amount...

I threw this together really fast...

Try changing

$output .= theme('pager', NULL, 20, 0);

to

$output .= theme('pager', NULL, $show_amount, 0);

...

It would make sense to add an admin setting that we can just load into $show_amount

mstef’s picture

I can't duplicate your problem. Even without my changes in #4 - it works fine. 30 items (granted there are at least 30 items in the system).

culfin’s picture

Hi mikestefff,

how can I include your snippet in my page?

Thanks,

Andreas

mstef’s picture

StatusFileSize
new30.69 KB

I changed the icons and edited the CSS a bit - so check that out...

(see attached)

culfin’s picture

Thanks, this looks great :-)

mstef’s picture

Some of the styling was specific for a theme I've been working on so you can do with it whatever you want..

vitalblue’s picture

Status: Needs review » Closed (outdated)