2010-07-25 5 views
2

Drupal은 SO 게시 질문 서식과 유사하게 api 형식으로 작성된 텍스트 영역의 맨 아래에 드래그 가능한 확장자를 추가합니다. 좋은 방법으로 이것을 어떻게 비활성화시킬 수 있습니까?드루팔 (Drupal의 텍스트 영역 확장기 사용 안 함?

+0

Drupal^ – kiamlaluno

+0

예와 함께 제공되는 파일을 변경하지 않고이를 수행하는 방법을 의미합니까? – Finbarr

+0

Rant - 왜 Drupal은 무능하게하기 위해 노력해야 할 여분의 무언가를 추가하지만, 단순히 메뉴 항목에 클래스를 추가하는 것과 같은 중요한 기능을위한 모듈을 설치해야합니까? – dayuloli

답변

8

드래그 가능한 확장 기능은 'misc/textearea.js'에 정의 된 동작을 통해 추가됩니다. 그것으로부터 당신은 그것이 '사이즈 변경 가능'클래스를 갖는 텍스트 영역에 적용된다는 것을 알 수 있습니다. the '#resizable' property on a textareas FAPI definition을 FALSE로 설정하면이 클래스의 출력을 막을 수 있습니다 (명시 적으로 설정하지 않으면 TRUE로 기본 설정됩니다).

자신 만의 양식으로 텍스트 영역을 적절하게 선언 할 수 있습니다. 다른 양식의 경우 hook_form_alter()을 통해 조정해야합니다.

+0

감사합니다. 나는 api를 여러 번 보았지만 그것을 볼 수 없었다. 나는'# expansionable '을 찾고 있었다! – Finbarr

0

가장 간단한 방법은 /misc/textarea.js 파일을 제거하는 것입니다.

더 힘들지만, 더 좋은 방법은 테마 또는 작은 모듈에서이를 수정하는 것입니다.

  • 자바 스크립트 파일 목록에서 textarea.js을 제거하는 전처리를 사용

    테마에

    , 당신은 다시 두 가지 옵션이 있습니다.

  • 렌더링 된 HTML에서 resizable-textarea 클래스를 제거하려면 테마 덮어 쓰기 (yourtheme_textarea)를 사용하십시오. 모듈에서 그 in the forums

옵션에 대한 일부 정보는 프로세서 물마루 어떤 형태와 실행 잡기 위해 hook_form_alter()를 실행하는 것입니다 :

/** 
* Implementation of hook_form_alter(). 
* 
* Before Drupal 7, there is no way to easily identify form fields that are 
* input format enabled. As a workaround, we assign a form #after_build 
* processing callback that is executed on all forms after they have been 
* completely built, so form elements are in their effective order 
* and position already. 
* 
* @see wysiwyg_process_form() 
*/ /** 
* Implementation of hook_form_alter(). 
* 
* Before Drupal 7, there is no way to easily identify form fields that are 
* input format enabled. As a workaround, we assign a form #after_build 
* processing callback that is executed on all forms after they have been 
* completely built, so form elements are in their effective order 
* and position already. 
* 
* @see wysiwyg_process_form() 
*/ 
function wysiwyg_form_alter(&$form, &$form_state) { 
    $form['#after_build'][] = 'wysiwyg_process_form'; 
    // Teaser splitter is unconditionally removed and NOT supported. 
    if (isset($form['body_field'])) { 
    unset($form['body_field']['teaser_js']); 
    } 
} 

function wysiwyg_process_form(&$form) { 
    // Iterate over element children; resetting array keys to access last index. 
    if ($children = array_values(element_children($form))) { 
    foreach ($children as $index => $item) { 
     $element = &$form[$item]; 

     // filter_form() always uses the key 'format'. We need a type-agnostic 
     // match to prevent false positives. Also, there must have been at least 
     // one element on this level. 
     if (($item === 'format' || $item === 'signature_format') && $index > 0) { 
     // Make sure we either match a input format selector or input format 
     // guidelines (displayed if user has access to one input format only). 
     if ((isset($element['#type']) && $element['#type'] == 'fieldset') || isset($element['format']['guidelines'])) { 
      // The element before this element is the target form field. 
      $field = &$form[$children[$index - 1]]; 

      $extra_class = ''; 
      if (!empty($field['#resizable'])) { 
      $extra_class = ' wysiwyg-resizable-1'; 
      drupal_add_js('misc/textarea.js'); 
      } 

      // If we loaded at least one editor, then the 'none' editor will 
      // handle resizable textareas instead of core. 
      if (isset($loaded) && !empty($field['#resizable'])) { 
      $field['#resizable'] = FALSE; 
      } 
     } 
     // If this element is 'format', do not recurse further. 
     continue; 
     } 
     // Recurse into children. 
     wysiwyg_process_form($element); 
    } 
    } 
    return $form; 
} 

이러한 예는 WYSIWYG 모듈 출신을 약간 변경되었습니다.

귀하의 테마는 훨씬 간단하지만 재정의 할 수있는 테마가 필요합니다. 이 모듈은 성능이 현저히 떨어지며 훨씬 더 복잡합니다. 그러나, 그것은 어떤 주제든지에 작동 할 것이다.

+0

/misc /에서 파일을 절대 제거하면 안됩니다. 사이트 디렉토리를 제외한 모든 것이 깨끗해야합니다. hook_form_alter는 그것을 제거하는 올바른 방법입니다. –

+0

나는 동의하지 않는다. 그럼에도 불구하고, 이것은 엄지 손가락의 좋은 규칙이며, Drupal Core를 만지지 않는 데는 많은 이유가 있지만, 그것은 Dogma입니다. 종종 여분의 코드, 모듈 관리 및 오버 헤드의 오버 헤드가 적절한 RCS에서 하나의 간단한 코어 패치를 관리 할 가치가 없습니다. – berkes

+0

테마 레이어에서로드하는 자바 스크립트 파일을 중지 할 수 있습니다. 테마 레이어를 삭제하는 것보다 바람직합니다. – cam8001

1
body textarea { 
    resize: none; 
} 
2

Disable Resizable Textarea이라는 새 모듈이 출시되었습니다.

이 항목은 텍스트 영역의 기본 #resizable 속성을 재정의하는 기능을 추가하는 간단한 모듈입니다. 기본적으로 모든 텍스트 영역은 크기 조정할 수 있습니다. 이 모듈을 사용하면 각 필드에서이 기능을 비활성화 할 수 있습니다.

설정이 매우 쉽습니다. 원하는 필드를 편집하면 "이 텍스트 영역의 #resizable 속성 비활성화"옵션이 표시됩니다. 필드의 유형이 "긴 텍스트 (요약 텍스트 포함)"인 경우 요약에서 크기 재조정을 비활성화 할 수도 있습니다.

0

Drupal (7)에서 크기를 조정할 수있는 텍스트 영역을 제거하는 방법이 있습니다.

1th 테마를 template.php에 넣으십시오. THEMENAME의 이름을 테마 이름으로 바꾸는 것을 잊지 마십시오.

/** 
* Override of theme('textarea'). 
* Deprecate misc/textarea.js in favor of using the 'resize' CSS3 property. 
*/ 

function THEMENAME_textarea($variables) { 
    $element = $variables ['element']; 
    element_set_attributes($element, array('id', 'name', 'cols', 'rows')); 
    _form_set_class($element, array('form-textarea')); 

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

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

2 다른 방법은 에게 Disable resizable textarea라는 또 다른 모듈을 사용하는 것입니다.

More info and source.