스마트에디터 여분필드 연동
본문
안녕하세요. 아래 내용을 참조해서 여분필드에 연동하였으나 조건이 달라서 그런지 잘안되네요.
https://gnustudy.com/bbs/board.php?bo_table=skin_board&wr_id=14
전 $wr_1 대신 동적변수인 fm_data_.$i을 사용해야 하는 상황입니다. $i값은 for loop의 인덱스값입니다.
예로 fm_data_1로 에디터는 불러와지나 write_update.php에 가서 찍어보면 fm_data_1이 넘어오지 않네요.
테이블 칼럼 wr_1에 변수 $fm_data_1의 값을 저장해야하며, write_update.php의 sql에 wr_1 = '{$fm_data_1}' 형태로 되어있습니다.
고수님들의 조언을 부탁드립니다.
스킨상단에 아래 코드가 추가했습니다.
require_once G5_EDITOR_LIB;
fwrite_submit에 추가한 editor_js 입니다.
function fwrite_submit(f)
{
<?php echo get_editor_js('fm_data_1'); ?>
<?php echo chk_editor_js('fm_data_1'); ?>
아래 코드의 경우 에디터가 안불러지고, fm_data_1값도 넘어가지 않음.
<div class="wr_content smarteditor2">
<?php echo editor_html("fm_data_1", $write['fm_data_1'], $is_dhtml_editor); ?>
</div>
아래 코드의 경우 에디터가 불러와지나, fm_data_1값이 넘어가지 않음.
<?php if($write_min || $write_max) { ?>
<small>이 게시판은 최소 <strong><?= $write_min; ?></strong>글자 이상, 최대 <strong><?= $write_max; ?></strong>글자 이하까지 글을 쓰실 수 있습니다.</small>
<?php } ?>
<?php if(!$is_dhtml_editor) $editor_html = str_replace('<textarea id="fm_data_1" name="fm_data_1"', '<textarea id="fm_data_1" name="fm_data_1" class="form-control"', $editor_html); ?>
<?= $editor_html; // 에디터 사용시는 에디터로, 아니면 textarea 로 노출 ?>
<?php if($write_min || $write_max) { ?>
<div class="d-flex justify-content-end"><small><span id="char_count"></span> 글자</small></div>
<?php } ?>
답변 2
require_once G5_EDITOR_LIB; <==write.php에서 이미 include하고 있으므로 필요없는 코드이고
나머지는 정상적으로 작동합니다
테스트 해보니 아래처럼 잘됩니다
[wr_link1] => [wr_link2] => [captcha_key] => 438626 [fm_data_1] =>
editor2 222222222222222222222
쓰기페이지에서 자바스크립트 에러가 있는지 확인해보세요
아래 코드의 경우 에디터가 안불러지고<===wr_content 에디터는 잘 나오는가요?
동적으로 구동하기 위해 아래와 같이 작성하였습니다.
write.php
if($w == ""){
$fm_data_1 = html_purifier($write['fm_data_1']);
}else{
$fm_data_1 = get_text($write['wr_1'], 0);
}
$editor_html_1 = editor_html('fm_data_1', $fm_data_1, $is_dhtml_editor);
... (중략)
write.skin.php
if($i == 1 ){ echo $editor_html_1; }if($i == 2 ){ echo $editor_html_2; }if($i == 3 ){ echo $editor_html_3; }if($i == 4 ){ echo $editor_html_4; }if($i == 5 ){ echo $editor_html_5; }
function fwrite_submit(f)
{
$('textarea[id]').each(function () {
var tid = $(this).attr('id'); // textarea의 id 값
var phpCode1 = `<?php echo get_editor_js('${tid}'); ?>`;
var phpCode2 = `<?php echo chk_editor_js('${tid}'); ?>`;
});
!-->!-->