Q&A

포인트 히스토리에 댓글추천 시에도 내역을 확인할 수 있게 하고 싶습니다

2021.07.25 05:00
347
0
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값을 받아오려면 소스를 어떻게 수정해야할까요? 

 

 

이미지 7.jpg

code_highlighter를 사용할 수 없어 부득이하게 DIV에 담은점은 양해부탁 드려요 

 

 

 

 

 

 

 

댓글 10

  • 2021.07.25 05:12 #1596098

    게시물(document)의 URL은 이미 받아오신 것 같은데요. 댓글의 URL을 말씀하시는 건가요?

    일단 Context에서 comment_srl 값을 받아오시면

    댓글의 URL은 아래의 형식대로 #comment_를 덧붙여서 만들 수 있습니다.

    https://xetown.com/questions/1596094#comment_1596098

  • 2021.07.25 05:32 #1596108

    $lang->point_message_comment_vote_up = '<b>%s</b>에서 댓글이 추천 받음 <b>( %s )</b>';

     

    ko.lang.php에서 설정한 point_message_comment_vote_up 내용입니다

     

    이미지 8.jpg

     

    하지만 결과값이 이렇게 찍히네요. 일단 문서 주소 자체를 못 받아오는 거 같습니다 T_T

  • 2021.07.25 05:29 #1596104

    정확히 안된다는게 어떤 것이 안된다는 것인지 게시물 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> )';

    이런식으로 미리 작성이 되어야 할 것 같구요.

  • 2021.07.25 05:33 #1596114

    웹지기님 답변 감사합니다

    댓글로 포인트 히스토리 값이랑 lang 내용을 추가하였습니다

     

    일단은 링크 걸기전에 주소값이라도 찍히는지 확인하고 있었습니다

  • 2021.07.25 05:35 #1596120

    위에 달아주신 내용으로 처리할때 문제가 보이는 부분은
    getUrl('', 'document_srl', $document_srl)

    이렇게 하지 않아서의 문제 같습니다.

    잘못된 변수로 인해 / 루트 주소만 가지게 되는 것 같구요.

  • 2021.07.25 05:41 #1596125

    이미지 9.jpg

     

    사실 첫소스가 이거였긴 했어요 이렇게해서 안되서 수정하다보니 T_T

     

    $document_srl에 값이 안 들어가는 거 같습니다

  • 2021.07.25 05:53 #1596132
    $comment_srl = Context::get('target_srl');
    $oCommentModel = getModel('comment');
    $oComment = $oCommentModel->getComment($comment_srl, FALSE, FALSE);
    $document_srl = $oComment->get('document_srl');

    이렇게 한번 시도해보시겠어요??
  • 2021.07.25 06:25 #1596145
    와!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    웹지기님 감사합니다 드디어 document_srl를 불러올 수 있습니다

    이제 댓글값까지 받아봐야겠네요 감사합니다 덕분에 해결했습니다 T_T
  • 2021.07.25 06:40 #1596153

    댓글 번호는 $comment_srl 입니다.
    #comment_$comment_srl 등으로 붙여줄 수있지만 페이지가 구분되는 곳에선 cpage 까지 작동되게 하는 것과 주소에서 cpage 를 포함하는 등의 작업도 필요합니다.

    페이지가 넘어가는 곳 못찾아가는 거 무시한담녀
    #comment_$comment_srl 이정도로 완성되게 하는 것으로 됩니다.

    - #comment_%s

  • 2021.07.25 12:03 #1596182
    답변 감사합니다! 웹지기님 덕분에 댓글추천 부분을 구현했어요 항상 많은 도움 주셔서 감사합니다 행복한 일요일 되세요