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

 
Phần 2 - Custom Image Search with Solr, Filefield Sources và Ctools

Phần 2 - Custom Image Search with Solr, Filefield Sources và Ctools

Drupal using Apache Solr, Filefield Sources, and Ctools. So far, we have created our custom FileField Source 

Hướng dẫn tạo Custom Field Formatter trong Drupal 8

Hướng dẫn tạo Custom Field Formatter trong Drupal 8

In Drupal, field values are displayed to the end user via a field formatter. Formatters that come with fields are often pretty basic. 

DrupalCon Austin monitoring session submissions

DrupalCon Austin monitoring session submissions

This is my fifth DrupalCon monitoring session submissions. My fifth time nervously counting the submissions as they come rolling in, first at a trickle, maybe 20 in a week. Then stagnation, followed by a bit of a panic - did we remember to tell people??

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

 

Diet con trung