일반페이지에서 텍스트에디터로 입력하기

일반페이지에서 텍스트에디터로 입력하기

QA

일반페이지에서 텍스트에디터로 입력하기

본문

일반페이지에서 게시판 글쓰기를 하려고
아래와 같이 작성하였습니다.

 

파일도 첨부되고 정상적으로 작동하는걸 확인하였는데
텍스트 에디터를 사용하고 싶어서
코드를 찾아보니 $editor_html을 출력하면 될꺼 같아서

아래와 같이 수정하였는데 텍스트 에디터가 출력이 안되네요.


관련된 js파일을 따로 불러와야 하는 건가요?

자바스크립트 전역변수 중 g5_editor 이것과 관련이 있을거 같은데 방법을 모르겠네요.


<?php
$sub_menu = 200100;
include_once(G5_PATH.'/head.php');
// board
$bo_table = 'notice';
$board = get_board_db($bo_table);
// token
$token = get_token();
set_session("ss_write_{$bo_table}_token", $token);
// file
$is_file = $board['bo_upload_count'] > 0;
$file_count = $board['bo_upload_count'] ?? 0;
?>

<div class="container">
    <h1>게시글 작성</h1>
    <form method="post" action="/bbs/write_update.php" enctype="multipart/form-data">
        <input type="hidden" name="bo_table" value="<?=$bo_table?>">
        <input type="hidden" name="token" value="<?=$token?>">
        <input type="hidden" name="return_url" value="/board/notice/?mode=list">
 
        <label for="wr_name">작성자</label>
        <input type="text" id="wr_name" name="wr_name" required>
        <label for="wr_subject">제목</label>
        <input type="text" id="wr_subject" name="wr_subject" required>
        <label for="wr_content">내용</label>
<!--        <textarea name="wr_content" id="" cols="30" rows="10"></textarea>-->
        <?php $editor_html = editor_html('wr_content', 'wr_content', '')?>
        <?php echo $editor_html;?>
 
        <?php for ($i=0; $is_file && $i<$file_count; $i++) : ?>
        <input type="file" name="bf_file[]">
        <?php endfor ;?>
        <button type="submit">작성</button>
    </form>
</div>
<?php
include_once(G5_PATH.'/tail.php');
?>

 

이 질문에 댓글 쓰기 :

답변 4


<?php
$sub_menu = 200100;
require_once '../common.php';
require_once G5_EDITOR_LIB;  // 에디터 라이브러리 로드
include_once(G5_PATH.'/head.php');
// board
$bo_table = 'notice';
$board = get_board_db($bo_table);
// token
$token = get_token();
set_session("ss_write_{$bo_table}_token", $token);
// file
$is_file = $board['bo_upload_count'] > 0;
$file_count = $board['bo_upload_count'] ?? 0;
?>
<div class="container">
    <h1>게시글 작성</h1>
    <form method="post" action="/bbs/write_update.php" enctype="multipart/form-data" onsubmit="return form_submit(this);">
        <input type="hidden" name="bo_table" value="<?=$bo_table?>">
        <input type="hidden" name="token" value="<?=$token?>">
        <input type="hidden" name="return_url" value="/board/notice/?mode=list">
 
        <label for="wr_name">작성자</label>
        <input type="text" id="wr_name" name="wr_name" required>
        <label for="wr_subject">제목</label>
        <input type="text" id="wr_subject" name="wr_subject" required>
        <label for="wr_content">내용</label>
        <?php echo editor_html('wr_content', '', 300); ?>
 
        <?php for ($i=0; $is_file && $i<$file_count; $i++) : ?>
        <input type="file" name="bf_file[]">
        <?php endfor ;?>
        <button type="submit">작성</button>
    </form>
    
    <script>
    function form_submit(f) {
        // 에디터 유효성 검사 및 처리
        <?php echo get_editor_js('wr_content'); ?>
        
        return true;
    }
    </script>
    
</div>
<?php
include_once(G5_PATH.'/tail.php');
?>

common.php는 어디서 불러오는가요?

1.

include_once(G5_EDITOR_LIB); <==이게 있어야 합니다

2.

하단에서 submit를 처리하는 자바스크립트 함수를 만들고

<?php echo get_editor_js("wr_content"); ?> 이것을 추가해야합니다

3.

write.skin.php에서  function fwrite_submit(f) 를 참고해서 만드세요

 

답변을 작성하시기 전에 로그인 해주세요.
전체 530
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT