여분필드로 스마트에디터 여러개 사용하는 문제 여쭤봅니다!
본문
이 글 참고해서 스마트에디터를 wr_content 외 3개 추가하였는데요
<write.skin.php>부분
<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="'.$board_skin_url.'/style.css">', 0);
if ($w == 'u') {
$wr_4 = get_text($write['wr_4'], 0);
$wr_5 = get_text($write['wr_5'], 0);
$wr_6 = get_text($write['wr_6'], 0);
}
?>
<section id="bo_w">
<div class="inner">
<h2 class="sound_only"><?php echo $g5['title'] ?></h2>
<!-- 게시물 작성/수정 시작 { -->
<form name="fwrite" id="fwrite" action="<?php echo $action_url ?>" onsubmit="return fwrite_submit(this);" method="post" enctype="multipart/form-data" autocomplete="off" style="width:<?php echo $width; ?>">
<input type="hidden" name="uid" value="<?php echo get_uniqid(); ?>">
<input type="hidden" name="w" value="<?php echo $w ?>">
<input type="hidden" name="bo_table" value="<?php echo $bo_table ?>">
<input type="hidden" name="wr_id" value="<?php echo $wr_id ?>">
<input type="hidden" name="sca" value="<?php echo $sca ?>">
<input type="hidden" name="sfl" value="<?php echo $sfl ?>">
<input type="hidden" name="stx" value="<?php echo $stx ?>">
<input type="hidden" name="spt" value="<?php echo $spt ?>">
<input type="hidden" name="sst" value="<?php echo $sst ?>">
<input type="hidden" name="sod" value="<?php echo $sod ?>">
<input type="hidden" name="page" value="<?php echo $page ?>">
<?php
$option = '';
$option_hidden = '';
if ($is_notice || $is_html || $is_secret || $is_mail) {
$option = '';
if ($is_notice) {
$option .= "\n".'<input type="checkbox" id="notice" name="notice" value="1" '.$notice_checked.'>'."\n".'<label for="notice">공지</label>';
}
if ($is_html) {
if ($is_dhtml_editor) {
$option_hidden .= '<input type="hidden" value="html1" name="html">';
} else {
$option .= "\n".'<input type="checkbox" id="html" name="html" onclick="html_auto_br(this);" value="'.$html_value.'" '.$html_checked.'>'."\n".'<label for="html">HTML</label>';
}
}
if ($is_secret) {
if ($is_admin || $is_secret==1) {
$option .= "\n".'<input type="checkbox" id="secret" name="secret" value="secret" '.$secret_checked.'>'."\n".'<label for="secret">비밀글</label>';
} else {
$option_hidden .= '<input type="hidden" name="secret" value="secret">';
}
}
if ($is_mail) {
$option .= "\n".'<input type="checkbox" id="mail" name="mail" value="mail" '.$recv_email_checked.'>'."\n".'<label for="mail">답변메일받기</label>';
}
}
echo $option_hidden;
?>
<?php if ($is_category) { ?>
<div class="bo_w_select write_div">
<label for="ca_name" class="sound_only">분류<strong>필수</strong></label>
<select name="ca_name" id="ca_name" required>
<option value="">분류를 선택하세요</option>
<?php echo $category_option ?>
</select>
</div>
<?php } ?>
<div class="bo_w_info write_div">
<?php if ($is_name) { ?>
<label for="wr_name" class="sound_only">이름<strong>필수</strong></label>
<input type="text" name="wr_name" value="<?php echo $name ?>" id="wr_name" required class="frm_input required" placeholder="이름">
<?php } ?>
<?php if ($is_password) { ?>
<label for="wr_password" class="sound_only">비밀번호<strong>필수</strong></label>
<input type="password" name="wr_password" id="wr_password" <?php echo $password_required ?> class="frm_input <?php echo $password_required ?>" placeholder="비밀번호">
<?php } ?>
<?php if ($is_email) { ?>
<label for="wr_email" class="sound_only">이메일</label>
<input type="text" name="wr_email" value="<?php echo $email ?>" id="wr_email" class="frm_input email " placeholder="이메일">
<?php } ?>
</div>
<?php if ($is_homepage) { ?>
<div class="write_div">
<label for="wr_homepage" class="sound_only">홈페이지</label>
<input type="text" name="wr_homepage" value="<?php echo $homepage ?>" id="wr_homepage" class="frm_input full_input" size="50" placeholder="홈페이지">
</div>
<?php } ?>
<?php if ($option) { ?>
<div class="write_div option_div">
<span class="sound_only">옵션</span>
<?php echo $option ?>
</div>
<?php } ?>
<div class="bo_w_tit write_div">
<label for="wr_subject" class="sound_only">제목<strong>필수</strong></label>
<div id="autosave_wrapper write_div">
<input type="text" name="wr_subject" value="<?php echo $subject ?>" id="wr_subject" required class="frm_input full_input required" size="50" maxlength="255" placeholder="제목">
<?php if ($is_member) { // 임시 저장된 글 기능 ?>
<script src="<?php echo G5_JS_URL; ?>/autosave.js"></script>
<?php if($editor_content_js) echo $editor_content_js; ?>
<button type="button" id="btn_autosave" class="btn_frmline">임시 저장된 글 (<span id="autosave_count"><?php echo $autosave_count; ?></span>)</button>
<div id="autosave_pop">
<strong>임시 저장된 글 목록</strong>
<ul></ul>
<div><button type="button" class="autosave_close">닫기</button></div>
</div>
<?php } ?>
</div>
<div class="wirte_div">
<input type="text" name="wr_1" id="wr_1" value="<?php echo $wr_1 ?>" placeholder="소제목">
</div>
<div class="wirte_div">
<textarea name="wr_2" id="wr_2" placeholder=""><?php echo $wr_2 ?></textarea>
</div>
</div>
<div class="write_div">
<label for="wr_content" class="sound_only">내용<strong>필수</strong></label>
<div class="wr_content <?php echo $is_dhtml_editor ? $config['cf_editor'] : ''; ?>">
<?php if($write_min || $write_max) { ?>
<!-- 최소/최대 글자 수 사용 시 -->
<p id="char_count_desc">이 게시판은 최소 <strong><?php echo $write_min; ?></strong>글자 이상, 최대 <strong><?php echo $write_max; ?></strong>글자 이하까지 글을 쓰실 수 있습니다.</p>
<?php } ?>
<?php echo $editor_html; // 에디터 사용시는 에디터로, 아니면 textarea 로 노출 ?>
<?php if($write_min || $write_max) { ?>
<!-- 최소/최대 글자 수 사용 시 -->
<div id="char_count_wrap"><span id="char_count"></span>글자</div>
<?php } ?>
</div>
</div>
<p>--정기구독회원만 볼 수 있는 컨텐츠입니다--</p>
<div class="write_div">
<input type="text" name="wr_3" id="wr_3" value="<?php echo $wr_3 ?>"> 작가의 INSPIRATION
</div>
<div class="write_div">
<label for="wr_4">Books</label>
<div class="wr_content"><?php echo editor_html("wr_4", $write['wr_4'], $is_dhtml_editor); ?></div>
</div>
<div class="write_div">
<label for="wr_5">Musics</label>
<div class="wr_content"><?php echo editor_html("wr_5", $write['wr_5'], $is_dhtml_editor); ?></div>
</div>
<div class="write_div">
<label for="wr_6">Movies</label>
<div class="wr_content"><?php echo editor_html("wr_6", $write['wr_6'], $is_dhtml_editor); ?></div>
</div>
<div class="write_div">
<label for="wr_7">작성자</label>
<input type="text" name="wr_7" id="wr_7" value="<?php echo $wr_7 ?>" placeholder="이름">
<input type="text" name="wr_8" id="wr_8" value="<?php echo $wr_8 ?>" placeholder="직급">
</div>
<?php for ($i=1; $is_link && $i<=G5_LINK_COUNT; $i++) { ?>
<div class="bo_w_link write_div">
<label for="wr_link<?php echo $i ?>"><i class="fa fa-link" aria-hidden="true"></i><span class="sound_only"> 링크 #<?php echo $i ?></span></label>
<input type="text" name="wr_link<?php echo $i ?>" value="<?php if($w=="u"){echo$write['wr_link'.$i];} ?>" id="wr_link<?php echo $i ?>" class="frm_input full_input" size="50">
</div>
<?php } ?>
<?php for ($i=0; $is_file && $i<$file_count; $i++) { ?>
<div class="bo_w_flie write_div">
<div class="file_wr write_div">
<label for="bf_file_<?php echo $i+1 ?>" class="lb_icon"><i class="fa fa-download" aria-hidden="true"></i><span class="sound_only"> 파일 #<?php echo $i+1 ?></span></label>
<input type="file" name="bf_file[]" id="bf_file_<?php echo $i+1 ?>" title="파일첨부 <?php echo $i+1 ?> : 용량 <?php echo $upload_max_filesize ?> 이하만 업로드 가능" class="frm_file ">
</div>
<?php if ($is_file_content) { ?>
<input type="text" name="bf_content[]" value="<?php echo ($w == 'u') ? $file[$i]['bf_content'] : ''; ?>" title="파일 설명을 입력해주세요." class="full_input frm_input" size="50" placeholder="파일 설명을 입력해주세요.">
<?php } ?>
<?php if($w == 'u' && $file[$i]['file']) { ?>
<span class="file_del">
<input type="checkbox" id="bf_file_del<?php echo $i ?>" name="bf_file_del[<?php echo $i; ?>]" value="1"> <label for="bf_file_del<?php echo $i ?>"><?php echo $file[$i]['source'].'('.$file[$i]['size'].')'; ?> 파일 삭제</label>
</span>
<?php } ?>
</div>
<?php } ?>
<?php if ($is_use_captcha) { //자동등록방지 ?>
<div class="write_div">
<?php echo $captcha_html ?>
</div>
<?php } ?>
<div class="btn_confirm write_div">
<a href="./board.php?bo_table=<?php echo $bo_table ?>" class="btn_cancel btn">취소</a>
<input type="submit" value="작성완료" id="btn_submit" accesskey="s" class="btn_submit btn">
</div>
</form>
<script>
<?php if($write_min || $write_max) { ?>
// 글자수 제한
var char_min = parseInt(<?php echo $write_min; ?>); // 최소
var char_max = parseInt(<?php echo $write_max; ?>); // 최대
check_byte("wr_content", "char_count");
$(function() {
$("#wr_content").on("keyup", function() {
check_byte("wr_content", "char_count");
});
});
<?php } ?>
function html_auto_br(obj)
{
if (obj.checked) {
result = confirm("자동 줄바꿈을 하시겠습니까?\n\n자동 줄바꿈은 게시물 내용중 줄바뀐 곳을<br>태그로 변환하는 기능입니다.");
if (result)
obj.value = "html2";
else
obj.value = "html1";
}
else
obj.value = "";
}
function fwrite_submit(f)
{
<?php echo get_editor_js("wr_4"); ?>
<?php echo get_editor_js("wr_5"); ?>
<?php echo get_editor_js("wr_6"); ?>
<?php echo $editor_js; // 에디터 사용시 자바스크립트에서 내용을 폼필드로 넣어주며 내용이 입력되었는지 검사함 ?>
var subject = "";
var content = "";
$.ajax({
url: g5_bbs_url+"/ajax.filter.php",
type: "POST",
data: {
"subject": f.wr_subject.value,
"content": f.wr_content.value
},
dataType: "json",
async: false,
cache: false,
success: function(data, textStatus) {
subject = data.subject;
content = data.content;
}
});
if (subject) {
alert("제목에 금지단어('"+subject+"')가 포함되어있습니다");
f.wr_subject.focus();
return false;
}
if (content) {
alert("내용에 금지단어('"+content+"')가 포함되어있습니다");
if (typeof(ed_wr_content) != "undefined")
ed_wr_content.returnFalse();
else
f.wr_content.focus();
return false;
}
if (document.getElementById("char_count")) {
if (char_min > 0 || char_max > 0) {
var cnt = parseInt(check_byte("wr_content", "char_count"));
if (char_min > 0 && char_min > cnt) {
alert("내용은 "+char_min+"글자 이상 쓰셔야 합니다.");
return false;
}
else if (char_max > 0 && char_max < cnt) {
alert("내용은 "+char_max+"글자 이하로 쓰셔야 합니다.");
return false;
}
}
}
<?php echo $captcha_js; // 캡챠 사용시 자바스크립트에서 입력된 캡챠를 검사함 ?>
document.getElementById("btn_submit").disabled = "disabled";
return true;
}
</script>
</div>
</section>
<!-- } 게시물 작성/수정 끝 -->
<view.skin.php> 부분
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
include_once(G5_LIB_PATH.'/thumbnail.lib.php');
// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="'.$board_skin_url.'/style.css">', 0);
?>
<script src="<?php echo G5_JS_URL; ?>/viewimageresize.js"></script>
<!-- 게시물 읽기 시작 { -->
<article id="bo_v" class="mag_v">
<div class="mag_v_vd">
<?$youtube_id = str_replace("https://youtu.be/", "", $view['wr_link1']);{?>
<iframe src="https://www.youtube.com/embed/<?php echo $youtube_id?>" frameborder="0" allowfullscreen></iframe>
<?}?>
</div>
<div class="inner">
<div class="mag_v_all">
<div class="left sticky">
<?php if ($category_name) { ?>
<span class="bo_v_cate"><?php echo $view['ca_name']; // 분류 출력 끝 ?></span><?php } ?>
<span class="bo_v_tit">
<?php
echo cut_str(get_text($view['wr_subject']), 70); // 글제목 출력
?></span>
<div class="bo_v_subtit"><?php echo $view['wr_1']?></div>
<div class="bo_v_info"><?php echo $view['wr_2']?></div>
</div>
<div class="right">
<div id="bo_v_con"><?php echo get_view_thumbnail($view['content']); ?></div>
<div class="bo_v_btm">
<ul class="share_ul">
<li>
<img src="" alt="">
<div class="txt">링크 공유</div>
</li>
<li>
<img src="" alt="">
<div class="txt">카카오톡 공유</div>
</li>
</ul>
<div class="bo_v_wr_info">
<div class="writer">
<span class="author"><?=$view['wr_7']?></span>
<span class="position"><?=$view['wr_8']?></span>
</div>
<div class="datetime">
<?php echo date("M d, Y", strtotime($view['wr_datetime'])) ?>
</div>
</div>
</div>
</div>
</div>
<div class="mag_v_special">
<div class="left">
<ul class="mag_v_insp">
<?if($view['wr_4'] != ""){?>
<li>
<div class="tit">Books</div>
<div class="cont"><?php echo $view['wr_4']; ?></div>
</li>
<?}?>
<?if($view['wr_5'] != ""){?>
<li>
<div class="tit">Musics</div>
<div class="cont"><?php echo $view['wr_5']; ?></div>
</li>
<?}?>
<?if($view['wr_6'] != ""){?>
<li>
<div class="tit">Movies</div>
<div class="cont"><?php echo $view['wr_6']; ?></div>
</li>
<?}?>
</ul>
<div class="bo_v_btm">
<ul class="share_ul">
<li>
<img src="" alt="">
<div class="txt">링크 공유</div>
</li>
<li>
<img src="" alt="">
<div class="txt">카카오톡 공유</div>
</li>
</ul>
<div class="bo_v_wr_info">
<div class="writer">
<span class="author"><?=$view['wr_7']?></span>
<span class="position"><?=$view['wr_8']?></span>
</div>
<div class="datetime">
<?php echo date("M d, Y", strtotime($view['wr_datetime'])) ?>
</div>
</div>
</div>
</div>
<div class="right sticky">
<div class="top"><?=$view['wr_3']?>작가의 <br><b>INSPIRATION</b>
</div>
</div>
</div>
<!-- 게시물 상단 버튼 시작 { -->
<?if($is_admin){?>
<div id="bo_v_top">
<?php
ob_start();
?>
<ul class="bo_v_left">
<?php if ($update_href) { ?><li><a href="<?php echo $update_href ?>" class="btn_b01 btn btn_change">수정</a></li><?php } ?>
<?php if ($delete_href) { ?><li><a href="<?php echo $delete_href ?>" class="btn_b01 btn btn_change" onclick="del(this.href); return false;">삭제</a></li><?php } ?>
<?php if ($copy_href) { ?><li><a href="<?php echo $copy_href ?>" class="btn_admin btn btn_change" onclick="board_move(this.href); return false;">복사</a></li><?php } ?>
<?php if ($move_href) { ?><li><a href="<?php echo $move_href ?>" class="btn_admin btn btn_change" onclick="board_move(this.href); return false;">이동</a></li><?php } ?>
<?php if ($search_href) { ?><li><a href="<?php echo $search_href ?>" class="btn_b01 btn btn_change">검색</a></li><?php } ?>
</ul>
<ul class="bo_v_com">
<li><a href="<?php echo $list_href ?>" class="btn_b01 btn btn_list">목록</a></li>
<?php if ($reply_href) { ?><li><a href="<?php echo $reply_href ?>" class="btn_b01 btn btn_answer">답변</a></li><?php } ?>
<?php if ($is_admin) { ?><li><a href="<?php echo $write_href ?>" class="btn_b02 btn btn_write">글쓰기</a></li><?php } ?>
</ul>
<?php if ($prev_href || $next_href) { ?>
<ul class="bo_v_nb">
<?php if ($prev_href) { ?><li class="btn_prv clearfix">
<span class="nb_tit">
<i class="fa fa-caret-up" aria-hidden="true"></i> 이전글
</span>
<a href="<?php echo $prev_href ?>">
<?php echo $prev_wr_subject;?>
<span class="nb_date"><?php echo str_replace('-', '.', substr($prev_wr_date, '2', '8')); ?></span>
</a> </li><?php } ?>
<?php if ($next_href) { ?><li class="btn_next clearfix"><span class="nb_tit"><i class="fa fa-caret-down" aria-hidden="true"></i> 다음글</span><a href="<?php echo $next_href ?>"><?php echo $next_wr_subject;?> <span class="nb_date"><?php echo str_replace('-', '.', substr($next_wr_date, '2', '8')); ?></span></a></li><?php } ?>
</ul>
<?php } ?>
<?php
$link_buttons = ob_get_contents();
ob_end_flush();
?>
</div>
<?}?>
<!-- } 게시물 상단 버튼 끝 -->
</div>
</article>
<!-- } 게시물 읽기 끝-->
<script>
<?php if ($board['bo_download_point'] < 0) { ?>
$(function() {
$("a.view_file_download").click(function() {
if(!g5_is_member) {
alert("다운로드 권한이 없습니다.\n회원이시라면 로그인 후 이용해 보십시오.");
return false;
}
var msg = "파일을 다운로드 하시면 포인트가 차감(<?php echo number_format($board['bo_download_point']) ?>점)됩니다.\n\n포인트는 게시물당 한번만 차감되며 다음에 다시 다운로드 하셔도 중복하여 차감하지 않습니다.\n\n그래도 다운로드 하시겠습니까?";
if(confirm(msg)) {
var href = $(this).attr("href")+"&js=on";
$(this).attr("href", href);
return true;
} else {
return false;
}
});
});
<?php } ?>
function board_move(href)
{
window.open(href, "boardmove", "left=50, top=50, width=500, height=550, scrollbars=1");
}
</script>
<script>
$(function() {
$("a.view_image").click(function() {
window.open(this.href, "large_image", "location=yes,links=no,toolbar=no,top=10,left=10,width=10,height=10,resizable=yes,scrollbars=no,status=no");
return false;
});
// 추천, 비추천
$("#good_button, #nogood_button").click(function() {
var $tx;
if(this.id == "good_button")
$tx = $("#bo_v_act_good");
else
$tx = $("#bo_v_act_nogood");
excute_good(this.href, $(this), $tx);
return false;
});
// 이미지 리사이즈
$("#bo_v_atc").viewimageresize();
//sns공유
$(".btn_share").click(function(){
$("#bo_v_sns").fadeIn();
});
$(document).mouseup(function (e) {
var container = $("#bo_v_sns");
if (!container.is(e.target) && container.has(e.target).length === 0){
container.css("display","none");
}
});
});
function excute_good(href, $el, $tx)
{
$.post(
href,
{ js: "on" },
function(data) {
if(data.error) {
alert(data.error);
return false;
}
if(data.count) {
$el.find("strong").text(number_format(String(data.count)));
if($tx.attr("id").search("nogood") > -1) {
$tx.text("이 글을 비추천하셨습니다.");
$tx.fadeIn(200).delay(2500).fadeOut(200);
} else {
$tx.text("이 글을 추천하셨습니다.");
$tx.fadeIn(200).delay(2500).fadeOut(200);
}
}
}, "json"
);
}
</script>
<!-- } 게시글 읽기 끝 -->
처음엔 잘 되는가 싶었는데 추가할게 있어서 여분필드를 10까지 다 쓰고 번호를 바꿨었는데
그때부터 값이 꼬이더니 코드를 이전으로 되돌려도 똑같네요 ㅠㅠ
에디터로 쓴 값들이 제대로 안나옵니다..
에디터로 사진 2개와 글을 쓰면 맨 처음 사진 하나만 나오고 그 후는 안나오거나..
아니면 텍스트 이후에 올린 이미지 경로가..
이런식으로 꼬여서 제대로 나오지 않습니다..
여분필드 값이 var(255)로 되어있어서 그런걸까요..?
처음엔 분명 문제없이 나왔었는데 그냥 운이 좋았던건지 ㅠ.. 코드를 되돌려도 그상태로 돌아가진 않아서..
혹시 wr_10 안의 여분필드값을 에디터를 사용해서 바꿀수있을까요?
제가 phpmyAdmin은 권한이 없어 사용할 수 없어서요 ㅠ
도움 부탁드립니다..
!-->!-->
답변을 작성하시기 전에 로그인 해주세요.