'Comment Box Settings', 'description' => 'Customize comment box sizes by content type.', 'page callback' => 'drupal_get_form', 'page arguments' => array('comment_box_settings'), 'access arguments' => array('administer site configuration'), 'type' => MENU_LOCAL_TASK, ); return $menu; } /** * Implements hook_form_alter(). * Change the comment textarea size. */ function comment_box_form_alter(&$form, $form_state, $form_id) { switch ($form_id) { case 'comment_form': global $user; drupal_add_css(drupal_get_path('module', 'comment_box') . '/comment_box.css'); $type = db_result(db_query("SELECT type FROM {node} WHERE nid = %d", $form['nid']['#value'])); // Set the texarea size. Note, Drupal always adds one extra row, so we decrement the value. $form['comment_filter']['comment']['#rows'] = variable_get("comment_box_size_$type", 10) - 1; // Add a class so it can be further styled in the CSS. $form['comment_filter']['comment']['#prefix'] = '
' . t('Enter the number of rows you wish each comment box to be for the listed content type.') . '
'); $types = node_get_types('names'); foreach ($types as $type => $name) { $var_name = "comment_box_size_$type"; $form[$var_name] = array( '#type' => 'textfield', '#title' => check_plain($name) . ' ', '#default_value' => variable_get($var_name, 10), '#attributes' => array('class' => 'container-inline'), ); } $form['clear'] = array('#value' => ''); return system_settings_form($form); }