포인트 히스토리에 댓글추천 시에도 내역을 확인할 수 있게 하고 싶습니다
CMS/프레임워크 | Rhymix 2.0 |
---|---|
개발 언어 | PHP 7.2 |
포인트 히스토리는 본문을 추천 받을 시엔 해당 내역을 자세히 안내하고 있지만 댓글 추천시에 안내하는 로직이 따로 없습니다
그래서 아래 소스를 추가해서 처리를 하려고 하는데 계속 값이 불러와지질 않네요 T_T
pointhistory.model.php
// 게시물 정보
if($document_srl = in_array($obj->act, array('procDocumentVoteUp', 'procDocumentVoteDown')) ? Context::get('target_srl') : Context::get('document_srl'))
{
$oDocument = getModel('document')->getDocument($document_srl);
if($oDocument->isExists())
{
$obj->reference_srl = $document_srl;
// 게시물 열람
if(!Context::get('act'))
{
$obj->message_type = 'read_document';
$obj->message = sprintf(Context::getLang('point_message_read_document'), $module_title, getUrl('', 'document_srl', $document_srl), cut_str($oDocument->get('title'), 30));
return array('type' => $obj->message_type, 'message' => $obj->message);
}
}
}
// ACT별 메세지
switch($obj->act)
{
// 추천 받음
case 'procDocumentVoteUp' :
$obj->message_type = 'vote_up';
$obj->message = sprintf(Context::getLang('point_message_document_vote_up'), $module_title, getUrl('', 'document_srl', $document_srl), cut_str($oDocument->get('title'), 30));
break;
// 비추천 받음
case 'procDocumentVoteDown' :
$obj->message_type = 'vote_down';
$obj->message = sprintf(Context::getLang('point_message_document_vote_down'), $module_title, getUrl('', 'document_srl', $document_srl), cut_str($oDocument->get('title'), 30));
break;
// 댓글 추천 받음 소스추가
case 'procCommentVoteUp' :
$document_srl = Context::get('document_srl');
$oDocument = getModel('document')->getDocument($document_srl);
$obj->reference_srl = $document_srl;
$obj->message_type = 'vote_up';
$obj->message = sprintf(Context::getLang('point_message_comment_vote_up'), $module_title, getUrl('', 'document_srl', $oDocument));
break;
댓글 추천 부분에 게시물의 url값을 받아오려면 소스를 어떻게 수정해야할까요?
code_highlighter를 사용할 수 없어 부득이하게 DIV에 담은점은 양해부탁 드려요
댓글 10
게시물(document)의 URL은 이미 받아오신 것 같은데요. 댓글의 URL을 말씀하시는 건가요?
일단 Context에서 comment_srl 값을 받아오시면
댓글의 URL은 아래의 형식대로 #comment_를 덧붙여서 만들 수 있습니다.
https://xetown.com/questions/1596094#comment_1596098
$lang->point_message_comment_vote_up = '<b>%s</b>에서 댓글이 추천 받음 <b>( %s )</b>';
ko.lang.php에서 설정한 point_message_comment_vote_up 내용입니다
하지만 결과값이 이렇게 찍히네요. 일단 문서 주소 자체를 못 받아오는 거 같습니다 T_T
정확히 안된다는게 어떤 것이 안된다는 것인지 게시물 url 값만 포인트히스토리 내역에서 안보인다는건지 아니면 그게 원인이라서 포인트 히스토리 내역에 흔적조차 없다는 건지 알수가 없네요.
우선 게시글 url 부분은
getUrl('', 'document_srl', $oDocument)
이부분이 이상해보입니다.
getUrl('', 'document_srl', $document_srl)
이렇게가 맞을 거 같구요.
그리고 내역에서 링크를 걸어줄때 게시글 제목도 필요하니
, cut_str($oDocument->get('title'), 30)
이부분도 추가되어야 할 것 같구요.
그리고 sprintf()
안에서 문법이 맞을 수 있도록
point_message_comment_vote_up 에 해당하는 부분이 /lang 폴더 안의 .php 파일안에
$lang->point_message_comment_vote_up = '%s에 올린 댓글이 추천받음 ( <a href = "%s">%s</a> )';
이런식으로 미리 작성이 되어야 할 것 같구요.
웹지기님 답변 감사합니다
댓글로 포인트 히스토리 값이랑 lang 내용을 추가하였습니다
일단은 링크 걸기전에 주소값이라도 찍히는지 확인하고 있었습니다
위에 달아주신 내용으로 처리할때 문제가 보이는 부분은
getUrl('', 'document_srl', $document_srl)
이렇게 하지 않아서의 문제 같습니다.
잘못된 변수로 인해 / 루트 주소만 가지게 되는 것 같구요.
사실 첫소스가 이거였긴 했어요 이렇게해서 안되서 수정하다보니 T_T
$document_srl에 값이 안 들어가는 거 같습니다
$oCommentModel = getModel('comment');
$oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE);
$document_srl = $oComment->get('document_srl');
이렇게 한번 시도해보시겠어요??
웹지기님 감사합니다 드디어 document_srl를 불러올 수 있습니다
이제 댓글값까지 받아봐야겠네요 감사합니다 덕분에 해결했습니다 T_T
댓글 번호는 $comment_srl 입니다.
#comment_$comment_srl 등으로 붙여줄 수있지만 페이지가 구분되는 곳에선 cpage 까지 작동되게 하는 것과 주소에서 cpage 를 포함하는 등의 작업도 필요합니다.
페이지가 넘어가는 곳 못찾아가는 거 무시한담녀
#comment_$comment_srl 이정도로 완성되게 하는 것으로 됩니다.
- #comment_%s