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

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

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:

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

Drupal 6

<?php

  function yourthemename_textarea($element)  {   
    $element['#resizable'] = false;
    return theme_textarea($element);
  }

?>

Drupal 7

Viết đè hàm theme('textarea')

function md_gallery_textarea($variables) {   
  $element = $variables['element'];   
  $element['#attributes']['name'] = $element['#name'];
  $element['#attributes']['id'] = $element['#id'];
  $element['#attributes']['cols'] = $element['#cols'];
  $element['#attributes']['rows'] = $element['#rows'];

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

  $wrapper_attributes = array(
    'class' => array('form-textarea-wrapper'),   
  );   
  if (!empty($element['#resizable'])) {   
    $wrapper_attributes['class'][] = 'resizable';   
  }   
  $output = '<div' . drupal_attributes($wrapper_attributes) . '>';   
  $output .= '<textarea' . drupal_attributes($element['#attributes']) . '>' . check_plain($element['#value']) . '</textarea>';   
  $output .= '</div>';
}

  return $output;
}

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

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Khanh Hoang

Khanh Hoang - Kenn

Kenn is a user experience designer and front end developer who enjoys creating beautiful and usable web and mobile experiences.

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Công ty Internet Trung Quốc ByteDance xoa dịu cơn giận của Trump

Công ty Internet Trung Quốc ByteDance xoa dịu cơn giận của Trump

ByteDance đang đưa ra đề xuất được tính toán kỹ lưỡng để chiều lòng Trump và duy trì hoạt động của TikTok ở Mỹ mà không phải chuyển giao thuật toán.

Hướng dẫn tạo Drupal Views Relationships và Entity References phức tạp

Hướng dẫn tạo Drupal Views Relationships và Entity References phức tạp

Drupal has some powerful tools for creating and managing complex content relationships. Views relationships using Entity References across more than one content type

Facebook "mở kho" ứng dụng cho giao diện Timeline

Facebook "mở kho" ứng dụng cho giao diện Timeline

Facebook bắt đầu cho phép người dùng sử dụng giao diện Timeline tải về các ứng dụng bổ sung để tích hợp vào "tường nhà".

Công ty diệt chuột T&C

 

Diet con trung