Drupal's default comments per page setting for content types is a select list with set options of 10, 30, 50, 70, etc.... It just so happens that for my forum topic content type I want 15 comments per page. So to save me having to dig around in the code to figure out what I have to change can anyone point me in the direction of what needs to be done to set my comments per page to 15 for my forum topic content type. Cheers.

Comments

Cory Goodwin’s picture

The function for the comments module is

function _comment_per_page() {
  return drupal_map_assoc(array(10, 30, 50, 70, 90, 150, 200, 250, 300));
}

Try to override it and post your results.

savioret’s picture

The right way:


function mymodule_form_alter(&$form, $form_state, $form_id) {
  // CHANGE number of post per comment form element
  if ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
    $form['comment']['comment_default_per_page']['#options'] = mymodule_comment_per_page();
  }
}

function mymodule_comment_per_page() {
  return drupal_map_assoc(array(5, 10, 15, 20, 25, 30, 40, 50, 70, 90, 150, 200, 250, 300));
}

jonask123’s picture

Hello, very useful post to me, looking for that feature for some time. But could you please write to me how and where (in wich file's) should I do this changes?

Thank you in advance!

P.S. I mean

jonask123’s picture

Hello, very useful post to me, looking for that feature for some time. But could you please write to me how and where (in wich file's) should I do this changes?

Thank you in advance!

RKS’s picture

You've probably already found your answer but if people (like me) come here and need to know I'll just say he's telling you to make a module. The "mymodule" is the giveaway and plus most people give the advice (properly) that you shouldn't hack your core files and override them with modules instead. That way, when you update, you don't undo all your hacks. Many people won't remember what they did to their core files and end up breaking their site without knowing what they changed they won't be able to fix it.

Heihachi88’s picture

Thanks, helped :)