"cssswitch"라는 자체 모듈을 만들었습니다. 나는 자신의 html 레이아웃을 만들어 모듈의 관리자 양식 부분을 표시하려고합니다. hook_form_alter()를 사용하여 양식 요소를 수정하는 방법을 알고 있지만 일부 양식이 서로 옆에 나타나도록 전체 양식 레이아웃을 만들어야합니다. theme_cssswitch_display()로 표시되는 노드의 프론트 엔드보기가있는 것처럼 보이지만 노드의 관리 부분에는 뭔가가 필요합니다. 당신이 다른 모듈에 정의되어있는 형식을 변경하려면 어떤 도움모듈에서 드루팔 (drupal) 형태의 레이아웃
3
A
답변
2
나는 이제 모든 것을 분류했습니다. 내 hook_theme은 이것이다 :
<style>
#edit-hour-start-wrapper, #edit-minute-start-wrapper, #edit-ampm-start-wrapper, #edit-hour-end-wrapper, #edit-minute-end-wrapper, #edit-ampm-end-wrapper {
float:left;
margin-right:25px;
}
</style>
<div id="regform1">
<?php print drupal_render($form['title']); ?>
<?php print drupal_render($form['cssfilename']); ?>
<fieldset class="group-account-basics collapsible">
<legend>Time Start</legend>
<?php print drupal_render($form['hour_start']); ?>
<?php print drupal_render($form['minute_start']); ?>
<?php print drupal_render($form['ampm_start']); ?>
</fieldset>
<fieldset class="group-account-basics collapsible"><legend>Time end</legend>
<?php print drupal_render($form['hour_end']); ?>
<?php print drupal_render($form['minute_end']); ?>
<?php print drupal_render($form['ampm_end']); ?>
</fieldset>
</div>
<?php print drupal_render($form['options']); ?>
<?php print drupal_render($form['author']); ?>
<?php print drupal_render($form['revision_information']); ?>
<?php print drupal_render($form['path']); ?>
<?php print drupal_render($form['attachments']); ?>
<?php print drupal_render($form['comment_settings']); ?>
<?php print drupal_render($form); ?>
: 나는 그 때 나는이 같은 모든 형태의 요소를 넣을 수있는 위치를 제어 할 수있는 파일 테마/환/cssswitch 노드 - form.tpl.php 을 만들어
function cssswitch_theme() {
return array(
'cssswitch_display' => array(
'arguments' => array('node'),
),
'cssswitch_node_form' => array(
'arguments' => array('form' => NULL),
'template' => 'cssswitch-node-form.tpl.php',
),
);
}
1
hook_form_alter
에 대한
function cssswitch_form_alter(&$form, $form_state, $form_id) {
switch($form_id) {
case 'cssswitch_node_form':
$form['hour_start']['#prefix'] = '<div class="start-box">';
$form['ampm_start']['#suffix'] = '</div>';
$form['ampm_start']['#attributes'] = array("style" => "border-width:2px;");
break;
}
}
function cssswitch_theme() {
return array(
'cssswitch_display' => array(
'arguments' => array('node'),
),
);
}
// to display the view of the node
function theme_cssswitch_display($node) {
$output = '<div class="cssswitch-cssfilename">Filename: '.
check_plain($node->cssfilename). '</div>';
$output .= '<div class="cssswitch-time_start">Start: '.
check_plain($node->hour_start). ':'.check_plain($node->minute_start).' '.check_plain($node->ampm_start).'</div>';
$output .= '<div class="cssswitch-time_end">End: '.
check_plain($node->hour_end). ':'.check_plain($node->minute_end).' '.check_plain($node->ampm_end).'</div>';
return $output;
}
감사 만 필요하다. 양식을 정의하기 때문에 양식을 변경할 필요가 없으며 원하는대로 양식을 정의 할 수 있습니다.
양식의 마크 업을 변경하려면 양식 자체 및/또는 요소의 속성이 #theme
이어야합니다. 그것으로 당신은 자신의 테마 함수를 사용하여 폼과 그것의 요소를 렌더링 할 수 있습니다.
Drupal's FAPI reference에서 도움을 찾으십시오.
0
내가 지금 필요한 대부분을 찾았습니다. Themer Info가 "cssswitch_node_form"이라는 "제안 된"양식 ID를 사용해야했습니다. "cssswitch_form()과 같은 양식 작성 함수에서 이것을 사용했습니다 : $ form [ '# theme'] = ' cssswitch_node_form ';
는 나는 또한이 기능에서 그 이름을 사용할 필요가: 여전히
function theme_cssswitch_node_form($form) {
$output='';
$output.='<span>testing 123</span>';
$output.=drupal_render($form['hour_start']['name']);
$output.=drupal_render($form['minute_start']);
$output .= drupal_render($form);
return $output;
}
내가 여기
function cssswitch_theme() {
return array(
'cssswitch_display' => array(
'arguments' => array('node'),
),
'cssswitch_node_form' => array(
'arguments' => array('form' => NULL),
),
);
그리고는 "theme_는"그 앞에 붙은 같은 이름의하지만과 기능입니다 자동으로 div로 자동으로 양식 요소를 둘러싼 html 코드 문제가 있습니다. 이 경우 일부 양식 요소를 나란히 배치하고 싶습니다. 나는 그것이 drupal_render() 함수가하는 일이라고 생각한다. 모든 HTML 마크 업없이 폼 요소를 제공하는 함수 호출이 있습니까?
감사합니다.
올바른 방향으로 나를 가리켜 주셔서 감사합니다. 지금은 거의 가지고 있다고 생각하지만, 내 양식은 내 모듈의 기능을 주제로하고 있지 않습니다.다음과 같이 폼 함수에 테마 함수 이름을 추가했습니다. $ form [ '# theme'] = 'cssswitch_form'; 함수 cssswitch_theme() { \t 창 어레이 ( \t 'cssswitch_display'=> 어레이 ( \t '인자'=> 어레이 ('노드') \t) \t 'cssswitch_form'=> 어레이 ( \t 'arguments'=> array(), \t), \t \t); } function theme_cssswitch_form ($ form) { $ output = ' 테스트 123'; $ output. = drupal_render ($ form); return $ output; } – EricP
@EricP 캐시를 지우는 것을 잊지 마십시오. 테마 기능에서 가장 일반적인 문제입니다. – googletorp