웹마스터 팁
댓글 새창으로 보기 (경로수정)
2009.10.20 17:38
소스코드를 수정하는 것이므로 반드시 백업을 해두실 것을 권합니다.
※ 첨부파일 경로 등 1,2번에 수정사항이 있습니다. (09.10.21)
목록에서 제목 옆에 있는 댓글수를 클릭해 댓글만 따로 새창으로 보는 팁입니다.
현재는 댓글 보기와 댓글 작성만 가능합니다.
수정/삭제/답글 기능은 기존 댓글 기능까지 건드려야 해서 나중에 기회가 되면 따로 올리도록 하겠습니다.
전에 게시물 새창으로 보기 팁과 비슷한 방식이라 적용 자체는 그리 어렵지 않습니다만
css 수정에 다소 애를 먹을 수 있습니다. 그래서 이번에도 샘플을 첨부하니 이대로 해보고 잘 되시면
자신만의 댓글창을 만들어보시길 바랍니다.
1. 첨부된 샘플파일을 다운 받아 다음과 같은 경로로 압축을 풉니다.
※ (수정) 범용성을 위해 경로를 modules/document 에서 modules/board로 수정했습니다.
이미 수정하신 분들은 죄송하지만 파일을 아래처럼 옮겨주시기 바랍니다.
popup_comment_layout.html => common/tpl/popup_comment_layout.html
commnet_pop.html => modules/board/tpl/commnet_pop.html
css/comment_pop.css => modules/board/tpl/css/comment_pop.css
images/이미지파일들 => modules/board/tpl/images/이미지파일들
2. modules/document/document.view.php 에서 적당한 곳에 다음 함수를 추가합니다.
※ 템플릿 디렉토리를 $this->setTemplatePath($this->module_path.'tpl'); 에서
$this->setTemplatePath('./modules/board/tpl'); 로 수정했습니다.
function dispDocumentCommentPopUp() {
// 목록 구현에 필요한 변수들을 가져온다
$document_srl = Context::get('document_srl');
// document 객체를 생성. 기본 데이터 구조의 경우 document모듈만 쓰면 만사 해결.. -_-;
$oDocumentModel = &getModel('document');
// 선택된 문서 표시를 위한 객체 생성
$oDocument = $oDocumentModel->getDocument($document_srl, $this->grant->manager);
if(!$oDocument->isExists()) return new Object(-1,'msg_invalid_request');
// 브라우저 타이틀 설정
Context::setBrowserTitle($oDocument->getTitleText());
Context::set('oDocument', $oDocument);
// 팝업 레이아웃 선택
$this->setLayoutPath('./common/tpl');
$this->setLayoutFile('popup_comment_layout');
$this->setTemplatePath('./modules/board/tpl');
$this->setTemplateFile('comment_pop');
}
3. modules/document/conf/module.xml 에서 19라인쯤에 다음을 추가합니다.
<action name="dispDocumentCommentPopUp" type="view" standalone="true" />
4. modules/board/tpl/js/board.js 에서 66라인쯤에 /* 댓글 글쓰기 작성후 */ 부분을 찾아 아래처럼 수정합니다.
var url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act','');
=> var url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl);
5. common/js/common.js 에서 popopen 함수를 찾아 그 밑에 아래처럼 popopen2 함수를 추가합니다.
function popopen2(url, target, pop_width, pop_height) {
if(typeof(target) == "undefined") target = "_blank";
if(typeof(xeVid)!='undefined' && url.indexOf(request_uri)>-1 && !url.getQuery('vid')) url = url.setQuery('vid',xeVid);
if(typeof(pop_width) == "undefined") pop_width = "350";
if(typeof(pop_height) == "undefined") pop_height = "120";
winopen(url, target, "left=10,top=10,width="+pop_width+",height="+pop_height+",scrollbars=yes,resizable=yes,toolbars=no");
}
6. 이제 스킨의 댓글 링크 부분을 수정합니다. 편의상 xe_official 게시판 스킨을 기준으로 설명드립니다.
modules/board/skins/xe_official/_style.list.html 에서 아래를 찾아
<a href="{getUrl('document_srl', $document->document_srl)}#comment"><span class="replyNum" title="Replies">[{$document->getCommentCount()}]</span></a>
다음과 같이 수정합니다.
<a href="{getUrl('document_srl',$document->document_srl,'act','dispDocumentCommentPopUp')}" onclick="popopen2(this.href,'CommPop',720,400); return false;"><span class="replyNum" title="Replies">[{$document->getCommentCount()}]</span></a>
다른 스킨에서도 댓글 수가 표시되는 부분을 찾아 위처럼 링크를 수정해주시면 됩니다.
리플창을 클릭시에
새창이 아니라 내용이 보이지 않고 리플만 보이는건 어떻게 해야되나요?
이러한 형식으로 중간에 내용이 있더라도 내용은 잘라먹고
리플만 출력시키고 싶습니다;; 굽실굽실 ㅠㅠ