comment_box.module in Util 6.3
Same filename and directory in other branches
Changes the size of the comment area.
File
contribs/comment_box/comment_box.moduleView source
<?php
/**
* @file
* Changes the size of the comment area.
*/
/**
* Implements hook_menu().
*/
function comment_box_menu() {
$menu['admin/settings/util/comment_box'] = array(
'title' => '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'] = '<div class="' . "comment-box-{$type}" . '">';
$form['comment_filter']['comment']['#suffix'] = '</div>';
return;
}
}
/**
* Module settings page.
*/
function comment_box_settings() {
drupal_add_css(drupal_get_path('module', 'comment_box') . '/comment_box.css');
$form = array();
$form['intro'] = array(
'#value' => '<p>' . t('Enter the number of rows you wish each comment box to be for the listed content type.') . '</p>',
);
$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' => '<div class="clear-block"></div>',
);
return system_settings_form($form);
}
Functions
Name![]() |
Description |
---|---|
comment_box_form_alter | Implements hook_form_alter(). Change the comment textarea size. |
comment_box_menu | Implements hook_menu(). |
comment_box_settings | Module settings page. |