[이윰] 새로고침 없이 댓글을 달거나 삭제할 수 있는 ajax 댓글 시스템으로 교체하기
페이지 정보

짧은주소
-
https://yadolee.com/tip/602 주소복사
본문
새로고침 없이 댓글을 달거나 삭제할 수 있는 ajax 댓글 시스템으로 교체하기
ajax 댓글 플러그인 v1.0 | https://sir.kr/g5_plugin/4972 |
상기 그누보드 링크를 참고해서 수정하였다.
1. 그누보드5/eyoom/user_program/board/delete_comment.skin.php 파일을 열어 다음과 수정한다.
만약 delete_comment.skin.php 파일이 없다면 UTF-8(BOM 없음) 인코딩으로 만들어서 진행한다.
수정 전
<?php
if (!defined('_GNUBOARD_')) exit;
// Your Program - Start
// Your Program - End
// 변수 할당하기 - /eyoom/inc/tpl.assign.php 파일 참조
$tpl->assign(array(
));
?>
수정 후
<?php
if (!defined('_GNUBOARD_')) exit;
// Your Program - Start
delete_cache_latest($bo_table);
echo G5_HTTP_BBS_URL.'/board.php?bo_table='.$bo_table.'&wr_id='.$write['wr_parent'];
exit;
// Your Program - End
// 변수 할당하기 - /eyoom/inc/tpl.assign.php 파일 참조
$tpl->assign(array(
));
?>
2. 그누보드5/eyoom/user_program/board/write_comment_update.skin.php 파일을 열어 다음과 수정한다.
만약 write_comment_update.skin.php 파일이 없다면 UTF-8(BOM 없음) 인코딩으로 만들어서 진행한다.
수정 전
<?php
if (!defined('_GNUBOARD_')) exit;
// Your Program - Start
// Your Program - End
// 변수 할당하기 - /eyoom/inc/tpl.assign.php 파일 참조
$tpl->assign(array(
));
?>
수정 후
<?php
if (!defined('_GNUBOARD_')) exit;
// Your Program - Start
delete_cache_latest($bo_table);
echo G5_HTTP_BBS_URL.'/board.php?bo_table='.$bo_table.'&wr_id='.$wr['wr_parent'].'#c_'.$comment_id;
exit;
// Your Program - End
// 변수 할당하기 - /eyoom/inc/tpl.assign.php 파일 참조
$tpl->assign(array(
));
?>
3. ajax 댓글 시스템을 사용할 스킨 폴더에 view_comment.skin.html 파일을 열어 다음과 같이 수정한다.
① onclick="return comment_delete();" 을 검색하여 다음과 같이 수정한다.
수정 전
onclick="return comment_delete();"
수정 후
onclick="return comment_delete(this);"
② <div class="view-comment"> 를 검색하여 다음과 같이 수정한다.
수정 전
<div class="view-comment">
수정 후
<div class="view-comment">
<ajaxcomment>
③ <!--{? eyoom_board.bo_use_cmt_infinite == '1'}--> 를 검색하여 다음과 같이 수정한다.
수정 전
<!--{? eyoom_board.bo_use_cmt_infinite == '1'}-->
수정 후
</ajaxcomment>
<!--{? eyoom_board.bo_use_cmt_infinite == '1'}-->
④ document.getElementById("btn_submit").disabled = "disabled"; 를 검색하여 다음과 같이 수정한다.
수정 전
document.getElementById("btn_submit").disabled = "disabled";
return true;
}
수정 후
document.getElementById("btn_submit").disabled = "disabled";
// ajax comment system
$.ajax({
url: f.action,
type: 'POST',
data: $(f).serialize(),
dataType: 'html',
})
.done(function(str) {
var tempDom = $('<output>').append($.parseHTML(str))
var title = $('title', tempDom).text()
if (title === '') {
// 1. commentBox 원위치
comment_box('', 'c')
// 2. commentBox Form 리셋
f.reset()
// 3. 코멘트 출력
$.ajax({
url: str,
type: 'GET',
dataType: 'html'
})
.done(function(str2) {
var tempDom2 = $('<output>').append($.parseHTML(str2))
$('ajaxcomment').replaceWith($('ajaxcomment', tempDom2))
})
}
<?php if ($is_guest) { ?>
// 4. 캡차 리로드
$('#captcha_reload').trigger('click')
<?php } ?>
document.getElementById("btn_submit").disabled = ""
})
return false;
}
⑤ function comment_delete() 를 검색하여 다음과 같이 수정한다.
수정 전
function comment_delete()
{
return confirm("이 댓글을 삭제하시겠습니까?");
}
수정 후
function comment_delete(that)
{
if (confirm('이 댓글을 삭제하시겠습니까?')) {
// ajax comment system
$.ajax({
url: that.href,
type: 'GET',
dataType: 'html',
})
.done(function(str) {
var tempDom = $('<output>').append($.parseHTML(str))
var title = $('title', tempDom).text()
if (title === '') {
// 1. commentBox 원위치
comment_box('', 'c')
// 2. 코멘트 출력
$.ajax({
url: str,
type: 'GET',
dataType: 'html'
})
.done(function(str2) {
var tempDom2 = $('<output>').append($.parseHTML(str2))
$('ajaxcomment').replaceWith($('ajaxcomment', tempDom2))
})
}
<?php if ($is_guest) { ?>
// 4. 캡차 리로드
$('#captcha_reload').trigger('click')
<?php } ?>
})
}
return false
}
추천인 2

레벨 148
경험치 3,275,688
Progress Bar 27.68%
- 가입일 : 2015-03-10 12:21:44
- 서명 : 인간에게 가장 큰 선물은
자기 자신에게 기회를 주는 것이다.
- 크리스 가드너, Chris Gardner -
- 자기소개 : There's never a shortcut to happiness.
-
[자유 게시판] 그러게나 말입니다{이모티콘}2025-09-19
-
[자유 게시판] 루루맘은 실시간으로 아메리카 퍼스트 필드 경기장에서 직관하셨더랍니다 미국에 비지니스 겸 여행 중이신데 솔트레이크시티가 주무대시라2025-09-19
-
[자유 게시판] 89세 나이시라 어쩌면 급작스러운 소식은 아니더라도 한없이 나약한 인간이기에 떠나는 이와 남겨진 이 나 또한 선택되어진다는 걸 깨닫게 됩니다.2025-09-17
-
[Web Server Tip] 저 또한 불편하단 느낌이 한동안 들었는데 막상 내려놓고 작업하니 시간이 소모될 뿐 문제될 건 없었습니다 차분하게 작업해 보세요{이모티콘}2025-09-10
-
[Web Server Tip] 패치할 양이 제법 많지만 그 기능을 사용하지 않더라도 충돌이 있다거나 하진 않았습니다 참고하세요2025-09-09
-
[이슈와 관심] 정경심 동양대 표창장 위조 판결 뒤집는 새로운 증거 나와 https://youtu.be/1ni0YkMIidM2025-08-13
-
[이슈와 관심] 외국 기사도 참고하셨음 좋겠습니다 {글}2025-07-18
-
[일일 메모장] 공감되는 말씀입니다2025-06-03
댓글4
하늘구장님의 댓글
shadow2fox님의 댓글
내사랑님의 댓글
축하합니다. 첫 댓글로 74경험치를 획득하였습니다.
shadow2fox님의 댓글