Mới nhất

Bỏ chức năng thay đổi kích thước textarea trong Drupal

By phantuanduy - Saturday, March 16, 2013 No Comments


Drupal cho phép bạn thay đổi kích thước của textarea, khi chưa có CSS3 thì điều này rất tiện dụng. Đến khi phần lớn các trình duyệt đã hỗ trợ CSS3 và bạn có thể thay đổi kích thước của textarea mà không cần tới javascript thì có thể đây là một chức năng hơi thừa. Để loại bỏ chức năng này trong drupal, bạn có thể thêm vào file template.php (ở trong thư mục theme mà bạn sử dụng) hàm sau:



Drupal 6
1
<?php
2
  function yourthemename_textarea($element)  {

3
    $element['#resizable'] = false;
4
    return theme_textarea($element); 

5
  }
6
?>
Drupal 7
Viết đè hàm theme('textarea')
01
function md_gallery_textarea($variables) {
02
  $element = $variables['element'];

03
  $element['#attributes']['name'] = $element['#name'];
04
  $element['#attributes']['id'] = $element['#id'];

05
  $element['#attributes']['cols'] = $element['#cols'];
06
  $element['#attributes']['rows'] = $element['#rows'];

07
  _form_set_class($element, array('form-textarea'));
08


09
  $wrapper_attributes = array(
10
    'class' => array('form-textarea-wrapper'),

11
  );
12


13
  if (!empty($element['#resizable'])) {
14
    $wrapper_attributes['class'][] = 'resizable';

15
  }
16


17
  $output = '<div' . drupal_attributes($wrapper_attributes) . '>';
18
  $output .= '<textarea' . drupal_attributes($element['#attributes']) . '>' . check_plain($element['#value']) . '</textarea>';

19
  $output .= '</div>';
20
  return $output;

21
}
Sau khi thêm hàm này, bạn cần phải xóa hết cache để xem kết quả.
Để xóa cache ở Drupal 6 bạn tìm đến đường link yourdomain.com/admin/settings/performance, và link cho Drupal 7 là yourdomain.com/admin/config/development/performance

người viết: Văn Huy



Xem danh mục tất cả các bài hướng dẫn về Drupal tại đây.


No Comment to " Bỏ chức năng thay đổi kích thước textarea trong Drupal "